开发者

AS3 regex - how to match 2 consecutive matches multiple times?

开发者 https://www.devze.com 2023-03-30 09:50 出处:网络
I have the following regex, which will match all the <br> and <br /> tags in a string: /<br[\\s|\\/]*>/gi

I have the following regex, which will match all the <br> and <br /> tags in a string:

/<br[\s|\/]*>/gi

I actually want to match every set of two consecutive tags, with valid matches being:

<br><br>
<br/><br>
<br><br/>
<br/><br/>
(and all variations with a space before the slash)

Obviously I can just double up the expressio开发者_JAVA百科n to /<br[\s|\/]*><br[\s|\/]*>/gi, but is there a shorter way of taking the first expression and saying "this, but twice"?


Try this one:

/(<br[\s|\/]*>){2}/gi

0

精彩评论

暂无评论...
验证码 换一张
取 消