Page 1 of 1

Regex help

Posted: Tue Mar 04, 2003 4:53 pm
by adamp
I'm having serious trouble getting a regular expression to work and would greatly appreciate any help.

I basically want to do stripslashes() on text in a string where it is between a {php} and {/php} tag.

A couple of things I've tried so far:

Code: Select all

$tmpl = preg_replace("!\{php\}(.|\s)+\{/php\}!e", "stripslashes('\\1')", $tmpl);
		$tmpl = preg_replace( "!\{php\}(ї^{]+)\{/php\}!e", "{php} stripslashes( '$1' ) {/php}", $tmpl );
Hopefully someone who understands regular expression better than me will have an answer :)

Posted: Tue Mar 04, 2003 9:13 pm
by lazy_yogi
this works

Code: Select all

$tmpl = preg_replace('/{php}(.*){\/php}/', "$1" , $tmpl);
but not when strip slashes is used

I assume you'll need to split it up and do what you need and join it back together