【问题标题】:Double Slash in URL and double slash for commentURL 中的双斜杠和评论的双斜杠
【发布时间】:2015-03-24 07:29:14
【问题描述】:

我想grep 双斜杠(PHP 中的注释),但它似乎与 URL 中的双斜杠冲突(http://) 我怎样才能从这个 url 获得直到行尾的第二个双斜杠?

http://goo // gle.com
http://goo//gle.com

我尝试过:grep -P -o ".//.{0,}",但它给了我输出

http://goo // gle.com
http://goo//gle.com

而我想要的是这样的输出:

// gle.com
//gle.com

那么,我该如何解析呢?

【问题讨论】:

    标签: php regex bash grep


    【解决方案1】:

    从协议中排除: 字符:

    grep -P -o "[^:]//.{0,}"
    

    执行:

    grep -P -o "[^:]//.{0,}" <<< "http://goo // gle.co"
    

    输出:

     // gle.co
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-19
      • 2010-12-14
      • 2018-03-18
      • 2021-02-07
      • 2012-02-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多