且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

没有扩展名的有效文件名的正则表达式

更新时间:2021-10-23 23:19:32

回复:


我需要一个正则表达式模式到
检查
字母数字(a-zA-z0-9)的字符串,并且
还包含下划线,hypen和点

I need a regular expression pattern to check a string for alphanumeric(a-zA-z0-9) and also can contain underscore, hypen and dot

模式将是[_ a-zA-Z0-9 \\-\\。] +

请注意双反斜杠,因为这首先被解释为Java字符串,反斜杠需要保持原样不变。

Note the double-backslashes, since this is first interpreted as a Java string and the backslashes need to stay intact for the regex.