我想获取两个标记之间的文本。ruby正则表达式扫描多个匹配
<b> foo</b>bar<br/>
=>bar
我尝试使用'<b>asdasd</b>qwe<br/>'.scan(/<b>[a-zA-Z0-9]*<\/b>(.*)<br\/>/)
,它给了我正确的结果。
但是当我试试这个:
'<b>exclude</b>op1<br/>exclude 2<b>exclude</b>op2<br/>exclude 2<b>exclude</b>op3<br/>exclude 2'.scan(/<b>[a-zA-Z0-9]*<\/b>(.*)<br\/>/) { |ele|
puts ele
}
它的第一<b>
标签和最后<br/>
标签相匹配,并返回整个字符串我期待的比赛
相关问题:http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self- contained-tags –