[英]How to check if string starts with a number, latin letter or underscore
请帮我做正则表达式,以检查主题中描述的内容。
您可以使用:
^[\\p{IsLatin}\\d_]
使用字符类:
if (str.matches("[0-9a-zA-Z_].*"))
Or simply use shortcut \\w
it's mean in java [a-zA-Z0-9_]
或简单地使用快捷方式\\w
这是java [a-zA-Z0-9_]
^\\w.*
You can also change ^
to \\\\A
if you want check the start of the string and not the start of the line 如果要检查字符串的开头而不是行的开头,也可以将^
更改为\\\\A
\\A\\w.*
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.