I want to get 116.83 and 81.16 from the below string. I tried \d but it also selects 2 from up2 and dn2. How can i ignore this.
<td align="right">
116.83<span class="up2"></span><br>81.16<span class="dn2"></span>
</td>
\b[\d.]+\b
\b matches the boundary between word and non-word characters, but doesn't include the adjacent characters in the match. Since letters and numbers are both word characters, it won't match between p and 2, so up2 doesn't match. But > is a non-word character, so it matches between > and 8, therefore the regexp matches 81.16.
\b[\d\.]+\b[], so it doesn't need to be escaped.Try something like this:
[>\s]+([\d\.]+)[<\s]+
But be sure to strip the leading > and whitespace as well as the trailing < and whitespace from the first level match OR take the second level matches only.
nodes = [].filter.call(elem.childNodes, function(x){return x.nodeType==3})