Regex: How to match a string that is not only numbers

后端 未结 11 824
夕颜
夕颜 2020-11-30 03:18

Is it possible to write a regular expression that matches all strings that does not only contain numbers? If we have these strings:

  • abc
11条回答
  •  南笙
    南笙 (楼主)
    2020-11-30 03:33

    Since you said "match", not just validate, the following regex will match correctly

    \b.*[a-zA-Z]+.*\b
    

    Passing Tests:

    abc
    a4c
    4bc
    ab4
    1b1
    11b
    b11
    

    Failing Tests:

    123
    

提交回复
热议问题