Preg_Replace $pattern syntax error

From: Date: Tue, 10 Jun 2008 00:07:15 +0000
Subject: Preg_Replace $pattern syntax error
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-275164@lists.php.net to get a copy of this message
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 (#275164) next »