svcghost — 2011-08-26T00:37:40-04:00 — #1
I've been struggling with this tricky REGEXP replace..
Basically, I want to replace all question marks with an @ symbol that appear BEFORE a slash. Only the ones that appear before the slash, leaving the ones that appear after the slash untouched.
I'd reallllyyy appreciate some help.
svcghost — 2011-08-26T01:02:23-04:00 — #2
Nevermind guys. I figured it out finally, sorry!
$string = preg_replace(/\\?(?=.*\\/)/i,'@',$string)
Basically, this says replace all question marks that have any character after them and finally a / ... So the first set of question marks match this because they have characters after them and then the slash, but the second set does not match because there is no slash afterwards