【问题标题】:Regex / parse with php正则表达式 / 用 php 解析
【发布时间】:2015-02-18 15:21:04
【问题描述】:

我在 PHP 中获得带有 CURL 的 html 并收到 html 页面。

在这个页面我可以看到这一行:

genereadresse('name','domain','com');

我想用正则表达式解析得到返回 name@domain.com

我不知道该怎么做。

【问题讨论】:

    标签: php regex parsing


    【解决方案1】:
    ^.*?\('([^']*)','([^']*)','([^']*)'\);.*$
    

    您可以试试这个。替换为$1@$2.$3\1@\2.\3。查看演示。

    https://regex101.com/r/uC8uO6/5

    $re = "/^.*?\\('([^']*)','([^']*)','([^']*)'\\);.*$/";
    $str = "genereadresse('name','domain','com');";
    $subst = "$1@$2.$3";
    
    $result = preg_replace($re, $subst, $str);
    

    【讨论】:

    • 我在 html 中还有其他内容想象:blablalalalalalalgenereadresse('name','domain','com');blablablalalala
    猜你喜欢
    • 1970-01-01
    • 2016-09-24
    • 2015-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多