简体   繁体   English

Javascript正则表达式以匹配确切的文件夹路径

[英]Javascript regex to match exact folder path

I have a folder structure like this: 我有这样的文件夹结构:

main
|__Test
   |__Sub
      |__Match
      |__Match1
      |__Match2

I have a requirement to: 我有以下要求:

  1. Match only one folder - "Match" 仅匹配一个文件夹-“匹配”
  2. Match multiple folder - "Match, Match1, Match2 匹配多个文件夹-“匹配,匹配1,匹配2

For a) I've tried: 对于a)我已经尝试过:

/main\/Test\/Sub\/Match\//

But that didn't help. 但这没有帮助。

Basically, I am using Isparta , and I need to exclude a few folders from instrumentation. 基本上,我正在使用Isparta ,并且需要从检测中排除一些文件夹。

试试这个:

\/main\/Test\/Sub\/Match([0-9])?\/?
/^main\/Test\/Sub\/Match[0-9]?\/?$/

I used [0-9] because you mentioned a structure Like. 我使用[0-9]是因为您提到了一个结构Like。 Assume there are not only match1 and match2. 假设不仅有match1和match2。

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

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