没有扩展名的有效文件名的正则表达式 [英] Regular expression for a valid filename without extension
本文介绍了没有扩展名的有效文件名的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要一个正则表达式模式来检查字符串是否为字母数字(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 this will be a file name so i dont want other character than this.
推荐答案
回复:
我需要一个正则表达式模式到
检查
字母数字(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.
这篇关于没有扩展名的有效文件名的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文