我有:
highlightedBlurb = "I love <strong class=\"highlight\">Apple</strong> and <strong class=\"highlight\">Apple</strong> products so so much"
我想将scan
与惰性模式匹配一起使用。我想要这样的东西:
[["<strong class=\"highlight\">Apple</strong>"], ["<strong class=\"highlight\">Apple</strong>"]]
我这样做了:
tokens = highlightedBlurb.scan(/(<strong class="highlight">.+<\/strong>)/)
我明白了:
[["<strong class=\"highlight\">Apple</strong> and <strong class=\"highlight\">Apple</strong>"]]
如何修改我的正则表达式?