I have a multiline XML blob in a Java String that I’d like to grep some values out of. I know that regexes and XML mix like crude oil and pasta, but I promise that I’m really not trying anything complicated.
Sample XML object String:
<ObjectDto>
<created>1313825589244</created>
<description>description</description>
<id>649</id>
<isFoo>true</isFoo>
<ObjectDto>
All I want is for object.matches("<isFoo>true</isFoo>") to evaluate to true. I’ve tried wrapping the meat of the regex in .* (and [\n.]* in case the newlines were throwing it), but no joy.
Why doesn’t it match?
I wasn’t matching newlines hard enough, turning on DOTALL
(?s).*<isFoo>true</isFoo>.*fixed it.