CancelImage Upload

Using the function sql_regcase() to convert search patterns into regular expressions

The PHP function sql_regcase() is ideal for regular expression newbies, as it converts any search patter with which it is provided into something a regexp function can use to analyse strings with.

Let's take the following code for instance:

<?php

$pattern = "This is my search pattern";

echo sql_regcase($pattern);

?>

The result of the above code will be:

[Tt][Hh][Ii][Ss] [Ii][Ss] [Mm][Yy] [Ss][Ee][Aa][Rr][Cc][Hh] [Pp][Aa][Tt][Tt][Ee][Rr][Nn]

Now doesn't that save time on having to place every letter into square brackets, and adding it's big or little brother for good measures?

Login
Want to leave a comment?

No problem. Just enter your email and password below.


register | home | reminder

myDesignTool Networking • www.mydesigntool.cominfo@mydesigntool.com