I am trying to determine if a string contains at least one XML tag using a function String.match(). Due to how the project is set up, I would prefer that I don't have to use it Pattern.
I am currently using this regex:
<[A-Za-z0-9]+>
Which, obviously, checks to see if there are arrows in the line on the right and left that contain the text. I need to check if a string has only one XML tag with Regex, for example, input:
blah <abc foo="bar">blah</abc> blah
blah <abc foo="bar"/>
but not entered as:
blah <abc> blah
blah <abc </abc> blah
Is it possible?
source
share