I want to match all words that doesn't include alphabet [a-zA-Z]
init.
Pass cases
Fail cases
I tried this regex /\b[^a-zA-Z ]+\b/
but it fails for some cases
You can use
(?<!\S)[^A-Za-z\s]+(?!\S)
See the regex demo.
Details:
(?<!\S)
- left-hand whitespace boundary[^A-Za-z\s]+
- one or more chars other than whitespace and ASCII letters (use [^\p{L}\s]+
to support all Unicode letters if supported)(?!\S)
- right-hand whitespace boundary.