2016-10-12 1 views
1

2レベル下の.htmlで終わるページのみを照合する必要があります。2レベルの深いページでのみ一致する

試合

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

ので基本的にはdomain-name.com/level-1/level-2/page-name.html

一致している必要があります

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 

と一致しません私は今、これらの可能性のいくつかに一致していません。私は何を使うべきですか?

現在の正規表現

/*/.*html$ 
+0

てみてください[ '/^HTTPS:?\/\ /(?:[^ \ /] + \/){3} [^ \ /。] + \。html $ /。test(url) '](https://regex101.com/r/Bhk3bS/1) –

答えて

1

これを試してみてください:

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

Explanation

関連する問題