Preg_Replace $pattern syntax error [solved]

From: Date: Tue, 10 Jun 2008 00:30:10 +0000
Subject: Preg_Replace $pattern syntax error [solved]
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-275165@lists.php.net to get a copy of this message
I needed to add the ~ character as a delimiter. So, the below now works $pattern='~<p\s+style="padding-left:\s+(\d+)px;">(.*?)</p>~'; G
Hi
How can I convert the regular expression:    <p\s+style="padding-left:\s+(\d+)px;">(.*?)</p>
into a pattern that PHP will accept? I am getting the error: Warning: preg_replace() [function.preg-replace]: Unknown modifier '(' in /Library/WebServer/Documents/tamagotchi/runtime/content/js/tiny_mce/examples/tinymce_regex.php on line 24 I am very new to regular expressions and any help is appreciated. Something to do with escaping certain strings? G $html =<<<EOB TinyMCE is a <span style="font-style: italic;">platform</span> <p style="text-align: center;">We recommend <a href="http://www.getfirefox.com" target="_blank">Firefox</a> </p> <p style="padding-left: 30px;">May the Regular Expression Find Me!</p> EOB; $pattern='<p\s+style="padding-left:\s+(\d+)px;">(.*?)</p>'; $replace= '<textformat indent=\\1>\\2</textformat>'; echo preg_replace($pattern,$replace, $html );


« previous php.general (#275165) next »