Not getting something with a regex

ABC

New Member
I attempted to answer this question (answer deleted, so here is my code).\[code\]<?phpfunction remove_get_param($uri, $name) { return preg_replace('/(?<=\?|&|;)' . preg_quote($name, '/') . '=[^&;]*/', '', $uri); }\[/code\]My initial code was consuming the first param such as \[code\]?\[/code\] when it shouldn't. I tried to do a lookbehind assertion but PHP said...\[quote\] Warning: preg_replace(): Compilation failed: nothing to repeat at offset 11 on line 4\[/quote\]I'm relatively new with regex assertions, but I assumed that a lookbehind assertion means make sure this pattern precedes, but don't consume it as part of the match.I looked up the syntax by googling regex cheetsheat and the resulting PNG I downloaded said that the syntax was \[code\]?<=\[/code\].What am I doing wrong?ThanksUpdateHello again. Here is some example usage that caused the warning above twice...\[code\]echo remove_get_param('http://mysite.com?param1=1&param2=2', 'param2') . "\n";echo remove_get_param('http://mysite.com?param1=1&param2=2', 'param1'); \[/code\]I should also mention I got these errors on codepad.org. Sorry for failing to mention that, I know codepad.org runs in a funky environment.
 
Back
Top