문제

I have a string like the following

this <b>is <i>a sample</i> string</b> with multiple <b>words and some</b> keywords <b>and partially formatted</b> text.

I need to get the between <b> and </b> where no nested <i> </i> tags. That is I need "words and some" as first match and "and partially formatted" as second match.

도움이 되었습니까?

해결책

use a regular expression like this :

<b>(?![^}]*(<i>|<\/i>))([^}]+?)<\/b>

demo here : http://regex101.com/r/zM1zO6

you will get the results in the second match group

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top