正则表达式匹配 2 个单词之间的所有特定字符(或匹配捕获组)
Regex match all specific chars between 2 words (or match within capture group)
尝试了 (?<=description\>)o(?=\<\/description)
和 (description)(.*?)(description))(o)
匹配 'description' 标签之间的所有 'o'。
不幸的是,我找不到这样做的方法。
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications with XML.</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world.</description>
</book>
</catalog>
您可以使用
(?:\G(?!\A)|<description>)(?:(?!</description>)[^o])*\Ko
尝试了 (?<=description\>)o(?=\<\/description)
和 (description)(.*?)(description))(o)
匹配 'description' 标签之间的所有 'o'。
不幸的是,我找不到这样做的方法。
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications with XML.</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world.</description>
</book>
</catalog>
您可以使用
(?:\G(?!\A)|<description>)(?:(?!</description>)[^o])*\Ko