简体   繁体   中英

repeat only once character regex in python

I want to match repeat character(/) only once in the middle of the string. At the start it must be http://www.website/shop . Now I am using this code and it matches all html. How can I restrict it.

'^[http://www.website/shop/].*.html$'

With this regex, no result ^[http://]\\W*(/){2}\\W

Valid

   http://www.website/shop/men.html
   http://www.website/shop/women.html

Invalid

   http://www.website/shop/men/footwear.html
   http://www.website/shop/men/causal.html
   http://www.website/shop/women/footwear.html

This regex should work

"http://www.website/shop/\w*.html"

... it won't match if there's another slash after the slashes in .../shop/

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