How do I address special characters in Regex? @ ? # $ % %...
this patten searches for a letter that comes between a prefix and a suffix.
$pattern = '/((?<!\b$PREFIX)$LETTER|$LETTER(?!$SUFFIX\b))/i';
$string = 'end';
$prefix = 'e';
$letter = 'n';
$suffix = 'd';
But what if $string
began with a #
$string = '#end';
$prefix = ???
edit: This is the preg_replace in full
$text = "<p>Newton, Einsteing and Edison. #end</p>"
$pattern = '/((?<!\b$PREFIX)$LETTER|$LETTER(?!$SUFFIX\b))/i';
echo preg_replace($pattern, '<b>\1</b>', $text);
this replaces all the n
letters with a bold n
but is supposed to exculde the n
in #end