I am using the regexp,
/(\<\s*?string(-array)?\s*?.*?\s*?\>\s*?)(.*)(\s*?\<\/string(-array)?\>)/
… to match all content between or tags of the form:
<string-array name="saveArray">
<item>Téléphone</item>
<item>Carte mémoires</item>
</string-array>
Problem is, I’m only able to match the contents of ‘string’ tags or arrays containing one item. When I replace the dot from the captured group in the middle with [^s], I get the content I want, but this solution would fail to match any content containing ‘s’. I tried a negative look-behind for ‘str’ immediately preceding the content (‘item-matching’) group, and it is giving me the same results.
Any help would be great!
You really should not parse xml using regexps.
That said, I think the thing that’s messing you up might be that “
.” (in many regexp engines, with default flags) matches any character except a newline.. So your.*will not match more than one line. Try replacing “.*” with “[\w\W]*“, or adding a regexp flag that says that “.” should match all characters.