views:

62

answers:

1

I'm running a simpler version of this regex:

<p\s*>(?:&(?:nbsp|\#0*160|x0*A0);|(?:<br\s*/?>)|[\s\u00A0]+)*</p>

On this string:

<p>paste in some bullets from word...</p><p>Firefox:</p><p>Bulleted list test:</p><ul><li>One </li><li>Two <ul><li>Sub item one </li><li>Sub 2 <ul><li>Subsub item1 </li><li>Subsub2</li></ul></li><li>Sub3</li></ul></li><li>Three </li><li>Four</li></ul><p>Ordered list test:</p><ol><li>one </li><li>two <ol><li>sub 1 </li><li>sub 2</li></ol></li></ol><p>                                                               i.      subsub 1</p><p>                                                             ii.      subsub 2</p><ol start="2"><ol start="3"><li>sub 3</li></ol><li>three </li><li>four</li></ol><p>test</p><p>IE6</p><p>Bulleted list test:</p><ul style="list-style-type: disc;"><li>One</li><li>Two<ul style="list-style-type: circle;"><li>Sub item one</li><li>Sub 2<ul style="list-style-type: square;"><li>Subsub item1</li><li>Subsub2</li></ul></li><li>Sub3</li></ul></li><li>Three</li><li>Four</li></ul><p> </p><p>Ordered list test:</p><ol style="list-style-type: decimal;"><li>one</li><li>two<ol style="list-style-type: lower-alpha;"><li>sub 1</li><li>sub 2</li></ol></li></ol><p>                                                               i.      subsub 1</p><p>                                                             ii.      subsub 2</p><ol style="list-style-type: decimal;" start="2"><ol style="list-style-type: lower-alpha;" start="3"><li>sub 3</li></ol><li>three</li><li>four</li></ol><br />

And the process spikes to 100% for seemingly infinity. I must be doing something redundantly/recursively with the regex but I'm not sure what. It exhibits the same behavior when testing the regex in Expresso.

A: 

This seems to fix it:

<p\s*>(?:&(?:nbsp|\#0*160|x0*A0);|(?:<br\s*/?>)|[\s\u00A0])*</p>

I think that the '+' was too redundant.

travis