简体   繁体   中英

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

For a) I've tried:

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

But that didn't help.

Basically, I am using Isparta , and I need to exclude a few folders from instrumentation.

试试这个:

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

I used [0-9] because you mentioned a structure Like. Assume there are not only match1 and match2.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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