0

I have HTML tag like <span class="value"> 0,0126 </span>, also with a comma or point as separator or decimal character, line break, 28 spaces before and after the number.

I want to match only the number with or without comma and/or point - like 1, 0,123 or 123.456,78.

I tried it with <span class="value">(.*)</span> and with <span="value">[^\s-]</span>- without success.

In the HTML code where the regex should match, is only one unique <span class="value">...</span>.

Evgeniy
  • 2,337
  • 2
  • 28
  • 68
  • 2
    [H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ](https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags) - use a parser, don't use regex. Also, `.` doesn't match `\n` – ctwheels Jan 29 '18 at 15:45
  • 1
    @ctwheels :) i would, but... a parser is for this task a nuclear overkill.... – Evgeniy Jan 29 '18 at 15:47
  • 1
    Then use `(.*?)` with `s` (single-line/dot all) flag or use `([\s\S]*?)` – ctwheels Jan 29 '18 at 15:48
  • @ctwheels you are the man ;) `([\s\S]*?)` works like a charm! – Evgeniy Jan 29 '18 at 15:53
  • `want to match only the number with or without comma and/or point` where is this in your regex attempt ? –  Jan 29 '18 at 16:02

1 Answers1

0

Maybe you have tabs instead of spaces. Could you try to check if it works: <span="value">[\s\t]*(\S+)[\s\t]*</span>

The regex will ignore all tabs and spaces before and after the number.