Regular Expression to return the contents of a HTML tag received as a string of text
- by Nathan Hernandez
I have a string in my code that I receive that contains some html tags. It is not part of the HTML page being displayed so I cannot grab the html tag contents using the DOM (i.e. document.getElementById('tag id').firstChild.data);
So, for example within the string of text would appear a tag like this:
12
My question is how would I use a regular expression to access the '12' numeric digit in this example? This quantity could be any number of digits (i.e. it is not always a double digit).
I have tried some regular expressions, but always end up getting the full span tag returned along with the contents. I only want the '12' in the example above, not the surrounding tag. The id of the tags will always be 'myQty' in the string of text I receive.
Thanks in advance for any help!