My RegExp is being greedy. There are two matches. The regexp is grabbing the
first span all the way to the last span. How do I prevent it from being
greedy?

Given this string:

Vestibulum <span style="text-decoration: underline;">aliquet</span>
<em>leo</em> in <b>enim</b> <span style="text-decoration:
line-through;">viverra</span> id lacinia arcu eleifend.

And this RegExp:

<span(.*)style="(.*)text-decoration:\s*underline(.*)"(.*)>(.*)</span>

// <span style="text-decoration: underline;">underline</span>
public var spanUnderlinePattern:RegExp =
/<span(.*)style="(.*)text-decoration:\s*underline(.*)"(.*)>(.*)<\/span>/gi;
public var spanUnderlinePatternReplace:String =
'<span$1style="$2$3"$4><u>$5</u></span>';

Result is:
Vestibulum <span style=";">aliquet</span> <em>leo</em> in <b>enim</b> <span
style="text-decoration: line-through;"><u>viverra</u></span> id lacinia arcu
eleifend.

Reply via email to