I have the following regex:
^\s*((\b[^0-9]+\b)\s*){2}$
This regex expects the string to have two words with no number. Thus, for instance, /^\s*((\b[^0-9]+\b)\s*){2}$/g.test('Word Otherword')
returns true
, as expected, and /^\s*((\b[^0-9]+\b)\s*){2}$/g.test('OnlyOneWord')
returns false
, as it contains only one word.
The problem is that Regex is treating accentuated characters like ã
or é
as words boundaries (\b
). This way, if I test /^\s*((\b[^0-9]+\b)\s*){2}$/g.test('João')
it returns `true', as it were two words instead of only one.
How could I solve this problem?