^(?![0-9]+$)[a-zA-Z0-9]+$
Try this.This будет убедиться, что вы по крайней мере одну цифру через negative looahead
См демки.
https://regex101.com/r/tX2bH4/43
NODE EXPLANATION
--------------------------------------------------------------------------------
^ the beginning of the string
--------------------------------------------------------------------------------
(?! look ahead to see if there is not:
--------------------------------------------------------------------------------
[0-9]+ any character of: '0' to '9' (1 or more
times (matching the most amount
possible))
--------------------------------------------------------------------------------
$ before an optional \n, and the end of
the string
--------------------------------------------------------------------------------
) end of look-ahead
--------------------------------------------------------------------------------
[a-zA-Z0-9]+ any character of: 'a' to 'z', 'A' to 'Z',
'0' to '9' (1 or more times (matching the
most amount possible))
--------------------------------------------------------------------------------
$ before an optional \n, and the end of the
string
попробовать '/ [A-Za-Z] /' –
Или, чтобы соответствовать строку только с букв или цифр, но не только цифры: '/^[A_Za-z0-9] * [ A-Za-z] [A-Za-z0-9] * $/', который, как я подозреваю, был тем, что нужно. (В зависимости от того, что понимается _alphanumeric_.) – ganbustein