regexregex-negation

Regex match words without alphabet


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


Solution

  • You can use

    (?<!\S)[^A-Za-z\s]+(?!\S)
    

    See the regex demo.

    Details: