正则表达式实现'http|https//:(.*?).shaoxing.com.cn'匹配规则的方法如下:

^(http|https)://(.*?).shaoxing.com.cn$

解释:

  • ^:表示字符串的开头
  • (http|https):表示匹配以 http 或 https 开头的字符串
  • ://:表示匹配冒号和双斜杠
  • (.*?):表示匹配任意字符,且非贪婪模式,即只匹配到第一个 .shaoxing.com.cn
  • shaoxing.com.cn:表示匹配以 shaoxing.com.cn 结尾的字符串
  • $:表示字符串的结尾

这个正则表达式可以匹配如下字符串:

  • http://www.shaoxing.com.cn
  • https://www.shaoxing.com.cn
  • http://abc.shaoxing.com.cn
  • https://xyz.shaoxing.com.cn

但是无法匹配如下字符串:

  • http://www.shaoxing.com
  • https://www.shaoxing.com
  • http://abc.shaoxing.com
  • https://xyz.shaoxing.com

因为这些字符串不符合以 .shaoxing.com.cn 结尾的规则。

正则表达式匹配域名:'http|https//:(.*?).shaoxing.com.cn' 规则详解

原文地址: https://www.cveoy.top/t/topic/olY9 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录