April 19th, 2010, 10:44 AM
I am new to RegEx and simply want to replace all occurrences of certain characters in a string while retaining the replaced character's case, for instance, if my string is "Anangelo" and I replace "an" with "<b>an</b>", I want the result to be :
April 19th, 2010, 11:49 PM
You can use preg_replace() function.
Originally Posted by gangelo
I think you are looking somethin like this only ?
$str = "Anangelo";
// CASE SENSITIVE //
$output = preg_replace("/An/","<b>An</b>",$str);
// IGNORE CASE SENSITIVE //
$output = preg_replace("/An/i","<b>An</b>",$str);
I will try my best !!!
April 20th, 2010, 07:41 AM
Originally Posted by web_developer