Help with regular expressions needed. I’m trying using regular expressions and preg_match_all find blocks <character>...</character>. Here is how my data looks like:
<character>
杜塞尔多夫
杜塞爾多夫
<div class="hp">dùsàiěrduōfū<div class="hp">dkfjdkfj</div></div>
<div class="tr"><span class="green"><i>г.</i></span> Duesseldorf (<i>Deutschland</i>)</div>
<div class="tr"></div>
</character>
<character>
我, 是谁
<div class="hp">текст</div>
<div class="tr">some text in different languages</div>
</character>
I tried \<character\>.*\<\/character> but unfortunately it didn’t work. Any suggestions?
If using the
pregfamily of functions, your regular expression should be:The non-greedy operator
?will prevent you from only getting one match starting from the first<character>and ending at the last</character>.The/sflag will allow your dot to match line breaks.