【问题标题】:regexp easy pattern [closed]正则表达式简单模式[关闭]
【发布时间】:2011-10-26 19:03:18
【问题描述】:

我有文字:

Hello please click this:  
    https://active.gameta.com/VE?service=proservice&c=CMzc-53lyIbqVBCXzc62-YP64BM&hl=pl.  
    And follow the instructions if you have problems click
    http://problems.com/contact.php

我需要这个https://active.gameta.com/VE?service=proservice&c=CMzc-53lyIbqVBCXzc62-YP64BM&hl=pl 怎么样?在 php 中的 regxp 中

【问题讨论】:

  • if (preg_match('%active\.gameta\.com/VE\?service=proservice&c=CMzc-53lyIbqVBCXzc62-YP64BM&hl=pl%', $subject, $regs)) { $结果 = $regs[0]; }
  • @FailedDev c= 是变化
  • 我不太确定你在问什么。您想在实际的 HTML 超链接中转换文本链接吗?
  • 我有纯文本,我只需要 active.gameta.com/… 但 c= 和 &hl= 可以更改

标签: php regex url


【解决方案1】:

有数百万种不同的正则表达式可以工作,因为您的问题非常模糊。请扩展您尝试过的内容,您想要做什么(替换/搜索/等)。但是……

这里有一些应该匹配(根据您的情况,可能需要用\/ 转义/):

https(.*)
https(.*)$
https:(.*)
https:(.*)$
https://(.*)
https://(.*)$
https://active\.gameta\.com/(.*)
https://active\.gameta\.com/(.*)$
etc...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-05
    • 2016-09-28
    • 2020-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多