我必须匹配一组具有一个或多个目录的URL。谁能帮我建立正则表达式。
下面是我正在为其构建正则表达式的Urls
1. /p-b/foo-id/Sas-p
2. /p-b/foo-id/cust-Sas-p
3. /p-b/foo-id/Sas-p/Sas-value-p
4. /p-b/foo-id/Sas-p/sm-deb-ad
5. /p-b/foo-id/Sas-p/sm-deb-ex
6. /p-b/foo-id/Sas-p/sm-deb-pl
7. /p-b/foo-id/Sas-p/po-2-ch
8. /p-b/foo-id/wm/5-y-6-p
9. /p-b/foo-id/wm/5-y-6-p/eq
10. /p-b/foo-id/wm/5-y-6-p/dv
11. /p-b/foo-id/wm/5-y-6-p/cu
12. /p-b/foo-id/wm/5-y-6-p/m
13. /p-b/foo-id/wm/5-y-6-p/others
14. /p-b/foo-id/pgm/my-first-foo
15. /p-b/foo-id/pgm/foo-fa
16. /p-b/foo-id/pgm/foo-ho
17. /p-b/foo-id/pgm/foo-vi
18. /p-b/ni-b/ni-ps/Sas-p/seafearer-p
19. /p-b/foo-first/gs
我构建了一个正则表达式,该正则表达式可以很好地用于以下URL,但是,我也得到了我不想包含的其他URL。
我构建的正则表达式:
(/p-b/(foo-id|ni-b|foo-first/(Sas-p|cust-Sas-p|wm|pgm|ni-ps|gs/(Sas-value-p|sm-deb-ad|sm-deb-ex|sm-deb-pl|po-2-ch|5-y-6-p|my-first-foo|foo-fa|foo-ho|foo-vi|Sas-p/(eq|dv|cu|m|others|seafearer-p))))).*