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 );


Reply via email to