I have an xml string that looks something like
<parent><child>value</child></parent>
I’m trying to write a regular expression that matches this string. Trick is, sometimes the input has random new lines and spaces in it.
For example:
<parent>
<child>value</child></parent>
I’d like to be able to identify using regex if the input xml has a parent, child and value.
So far I’ve tried:
“<parent>\n\s*<child>value<\/child>”
But this doesn’t seem to match. I don’t understand how to ignore ALL whitespace and ALL new lines in my expression.
SOLUTION: So when you are working with older systems, in healthcare tools for example you may often need to match xml requests and it's very much possible... through trial and error here's what worked for me:
^<parent>\s*<child>value[\S\s]*