Hey all,
I'm dealing with an issue where I'm trying to search for a link, and replace that link with something else. I'm sure you can imagine the problems when links contain common characters such ? and +. Is there a modifier available for php use to designate that a particular string should be treated literally, with no interpretation? I know that perl has the use of \Q, but thats a string modifier, not a regex modifier, and pregs don't support it.
I'd like to do something along the lines of
/regexstuff+(my string with ? and + designated literal with a modifier)regexstuff+/
It's something I feel like has to be there, I just haven't found it yet - but the more I look around, the more I suspect I may be sol on this one.
It's not as pretty as I would like, but what would ya'll think of doing a
preg_replace("/([\$.|[](){}?*+])/", "\\$1", $string_to_be_literal);
Do you think it would catch everything perl regexes like to interpret?