Rails format validation — alphanumeric, but not purely numeric

前端 未结 1 1568
慢半拍i
慢半拍i 2021-01-13 11:23

Whats the best way to test a format validation of lets says a username, with a regex for alphanumeric, but not purely numeric?

I\'ve been using the following validat

1条回答
  •  伪装坚强ぢ
    2021-01-13 12:00

    You want to 'look ahead' for a letter:

    /\A(?=.*[a-z])[a-z\d]+\Z/i
    

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