简体   繁体   中英

Match only for 2 level deep pages

So need to match for only pages ending with .html down two levels deep.

match

http://www.example.com/bedroom/beds/select-queen-platform-bed.html

not match

http://www.example.com/bedroom/select-queen-platform-bed.html
http://www.example.com/bedroom/
http://www.example.com/
http://www.example.com/bedroom/beds/level3/select-queen-platform-bed.html

so basically it should match domain-name.com/level-1/level-2/page-name.html

The expression I have now doesn't match for some of these possibilities. What should I use?

current regex

/*/.*html$

Try this:

^http:\/\/(?:(?:[^\/]+)\/){3}[^\/]+\.html$

Explanation

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