简体   繁体   English

正则表达式仅允许使用字母和正斜杠

[英]Regular expression allowing alphabets and forward slash only

my requirement is that i need to get input from user regarding a folder path the validation which I require for it is i need users to input only alphabets and forward slash(no other special characters and also no space), also the forward slash is optional. 我的要求是我需要从用户那里获得有关文件夹路径的输入,我需要进行验证,因为我需要用户仅输入字母和正斜杠(没有其他特殊字符,也没有空格),而且正斜杠是可选的。

For Example : 例如 :

FlceIn - Valid Path FlceIn-有效路径

FlceIn/ - Valid Path FlceIn /-有效路径

FlceIn\\ - In Valid Path FlceIn \\-有效路径中

FlceIn/Name/ - Valid Path FlceIn / Name /-有效路径

Currently after goggling the i am using the expression [a-zA-Z//] but it does not seem to work. 目前,我在浏览后正在使用表达式[a-zA-Z //],但它似乎不起作用。

^([A-Za-z/]*)$ will match what you are describing. ^([A-Za-z/]*)$将与您所描述的匹配。 Regular expressions require a lot of learning and practice, a lot of study on the subject is definitely recommended. 正则表达式需要大量的学习和实践,因此绝对建议您对该主题进行大量的研究。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM