I am currently using a regular expression that accepts only alphabets, like
?:[a-z][a-z]+
I have also used a regular expression that accepts alphanumeric but it does not meet my requirements
My strings are in following pattern
"john" or "john123"
Any kind of help would be appreciated
试试^[a-zA-Z0-9]+$
,这个对我^[a-zA-Z0-9]+$
尝试使用此^([A-Za-z]|[0-9])+$
您可以使用(:?[a-z0-9][a-z0-9]*)
' 不捕获 '或([a-z0-9][a-z0-9]*)
' 捕获 ' 区分大小写模式以匹配字母数字单词,具体取决于您是否要捕获与正则表达式匹配的单词。
此正则表达式在String的开头接受字母,在末尾接受字母数字,您可以在https://regex101.com/中对其进行测试
^[A-Za-z][A-Za-z0-9]*(?:_[A-Za-z0-9]+)*$
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.