Regex: only alphanumeric but not if this is pure numeric

后端 未结 7 1952
北荒
北荒 2020-11-29 11:34

For instance:

\'1\'     => NG
\'243\'   => NG
\'1av\'   => OK
\'pRo\'   => OK
\'123k%\' => NG

I tried with

          


        
相关标签:
7条回答
  • 2020-11-29 12:18

    Use

    /^(?![0-9]*$)[a-zA-Z0-9]+$/
    

    This expression has a negative lookahead to verify that the string is not only numbers. See it in action with RegExr.

    0 讨论(0)
提交回复
热议问题