使用正则表达式验证文件夹路径 [英] Validate a folder path using regular expression

查看:541
本文介绍了使用正则表达式验证文件夹路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,我想验证路径格式说

c:\ abcFolder通过正则表达式plz帮助



什么我试过了:



i尝试了这样的正则表达式

Dear friends i want to validate a path format say
c:\abcFolder through regular expression plz help

What I have tried:

i have tried regular expression like this

^((([a-zA-Z]:)(\\{2}[a-zA-Z]+)(\\{2}\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))(?=(\\(\w[\w ]*)))(\\\w[\w ]*)*)$

推荐答案


正则表达式以验证文件路径和扩展名 [ ^ ]


使用最后一个链接查看您的RegEx的漂亮图表。

我不知道您期望与之匹配这个RegEx,但它看起来非常错误。

您应该改进您的问题并准确描述您想要(并且不希望)匹配的内容。顺便说一句,你使用的语言也很重要。



只是一些有趣的链接来帮助构建和调试RegEx。

这是一个链接到RegEx文档:

perlre - perldoc.perl.org [ ^ ]

以下是帮助构建RegEx的工具的链接调试它们:

.NET正则表达式测试程序 - 正则表达式风暴 [ ^ ]

Expresso正则表达式工具 [ ^ ]

这个显示RegEx是一个很好的图表,它非常有助于理解RegEx的作用:

Debuggex:在线可视正则表达式测试器。 JavaScript,Python和PCRE。 [ ^ ]
Use last link to see a nice graph of your RegEx.
I don't know what you expect to match with this RegEx, but it look very wrong.
You should improve your question and describe precisely what you want (and don't want) to match. By the way, the language you use matters too.

Just a few interesting links to help building and debugging RegEx.
Here is a link to RegEx documentation:
perlre - perldoc.perl.org[^]
Here is links to tools to help build RegEx and debug them:
.NET Regex Tester - Regex Storm[^]
Expresso Regular Expression Tool[^]
This one show you the RegEx as a nice graph which is really helpful to understand what is doing a RegEx:
Debuggex: Online visual regex tester. JavaScript, Python, and PCRE.[^]


这篇关于使用正则表达式验证文件夹路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆