Darline
Darline

Reputation: 195

regex catch the 'end tag on html'

I have this regex which cathes tags on html but the problem is it won't catch the last end tag.

REGEX: (<[^>]*value=")month("[^>]*>)([^<]*)(<[^>]*>)

HTML TAG: <option value="month">MONTH</option></select>

i don't know how to catch the </select> tag. I tried putting another (<[^>]*>) which result from no match found in the html.

HERE'S the LINK where I test my regex. Any help?

Upvotes: 0

Views: 126

Answers (1)

Casimir et Hippolyte
Casimir et Hippolyte

Reputation: 89557

It's because you have forgotten the newline between </option>and </select>

You must add \s* (or \n if you are sure that the newline is the only white space):

(<[^>]*value=")month("[^>]*>)([^<]*)(<[^>]*>)\s*(<[^>]*>)

But what are you trying to do?

about character class

Upvotes: 1

Related Questions