【问题标题】:Regex pattern for URL string [duplicate]URL 字符串的正则表达式模式 [重复]
【发布时间】:2020-02-15 12:16:46
【问题描述】:

我需要找到 url 的正则表达式模式并使用 regex.test() 所以只有这样的字符串:

http://*.margonem.pl/

所以它和上面的字符串完全一样,* 必须出现在哪里,并且可以是只包含a-z 字母而没有任何符号的字符串。

【问题讨论】:

  • ^http://(?:[a-z]+\.)?margonem\.pl/$^http:\/\/(?:[a-z]+\.)?margonem\.pl\/$(取决于使用情况)。

标签: javascript regex


【解决方案1】:

那就是http:\/\/[a-z]+\.margonem\.pl\/:

匹配

http://a.margonem.pl/
http://foo.margonem.pl/

不匹配

http://hello-world.margonem.pl/
http://abcq443435u4531.margonem.pl/

【讨论】:

  • @dopeCode 为什么不呢? www 可以是子域。
  • 抱歉没关系
猜你喜欢
  • 2023-03-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-11-28
  • 2019-11-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多