I would like to match the whole "word"—one that starts with a number character and that may include special characters but does not end with a '%'.
Match these:
- 112 (whole numbers)
- 10-12 (ranges)
- 11/2 (fractions)
- 11.2 (decimal numbers)
- 1,200 (thousand separator)
but not
- 12% (percentages)
- A38 (words starting with a alphabetic character)
I've tried these regular expressions:
(\b\p{N}\S)*)
but that returns '12%' in '12%'
(\b\p{N}(?:(?!%)\S)*)
but that returns '12' in '12%'
Can I make an exception to the \S
term that disregards %
?
Or will have to do something else?
I'll be using it in PHP, but just write as you would like and I'll convert it to PHP.
\S
(which means non-space)? – Lely