I have a function that through regular expression removes html content:
a.replace( /<.*?>/g, "");
However, if there are spaces they remain, for example:
<a href='site.com'> testing</a>
That will keep the spaces. Also for something like this:
<a href='site.com'> $20</a>
I would like the function to return only 20. So, the question is:
How do I modify the regular expression so that $ and spaces get removed as well?
a.innerText = "";or$(a).text("");Regex is not the tool you're looking for.jQuery("<a href='site.com'> $20</a>").text()returns " $20" (StackOverflow strips the spaces) which is easier to process. ContinuingjQuery(…).text().replace(/[\s$]*/, '')results in20.