I need to match the numbers inside a html tag. IE
Sometext<sometag><htmltag>123123</htmltag></sometag>
I need to create a regex that finds the number that is inside the html tag of my choice, in this case the <htmltag>
Thanks everyone :)
I need to match the numbers inside a html tag. IE
Sometext<sometag><htmltag>123123</htmltag></sometag>
I need to create a regex that finds the number that is inside the html tag of my choice, in this case the <htmltag>
Thanks everyone :)
If all there is between those two tags is the number, and absolutely no white space or anything, you can simply use this regex:
/<htmltag>([0-9]+)<\/htmltag>/
Or this if there might be whitespace:
/<htmltag>\s*([0-9]+)\s*<\/htmltag>/
No, you don't need to "match", you need to extract an HTML node. Use an HTML parser. An HTML parser is simpler to use, more robust against changes, and easier to extend (e.g. grabbing more parts of the same document). A regular expression, on the other hand, is just the wrong tool, because HTML is not a regular language.