Are str_replace and preg_replace case sensitive?
Printable View
Are str_replace and preg_replace case sensitive?
Believe so *looks at the docs*
str_replace:
Quote:
[email protected]
27-May-2001 11:58
It should be noted in the docs that str_replace() is Case Sensitive. This
makes sense of course, as that is the quickest way to solve problems. It
would be interesting to see something like stri_replace(), an insensitive
replace. Hmm..(goes to check CVS)
...and preg_replace:
Quote:
[email protected]
19-Apr-2002 10:04
If you want to quote strings case insensitively, without altering the case
of the actual match (like google does) :
$text = "Reading the documentation is allways recommanded, and the
PHP manual is worth a read";
$search = "read";
$text =
preg_replace("'$search'i","<b>\\0</b>",$text);
/*
* will output :
* <b>Read</b>ing the documentation is allways
* recommanded, and the PHP manual is
* worth a <b>read</b>.
*
*/
damn, then how can you do a normal case insensative replace?