首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >将注释的多行(freespace)正则表达式传递给preg_match?

将注释的多行(freespace)正则表达式传递给preg_match?
EN

Stack Overflow用户
提问于 2018-05-03 07:22:19
回答 2查看 0关注 0票数 0

我有一个正则表达式,最终会变得有点长,并且它可以使它更容易阅读并跨越多行。

代码语言:javascript
复制
preg_match('
                ^J[0-9]{7}:\s+
                (.*?)             #Extract the Transaction Start Date msg
                \s+J[0-9]{7}:\s+Project\sname:\s+
                (.*?)             #Extract the Project Name
                    \s+J[0-9]{7}:\s+Job\sname:\s+
                (.*?)             #Extract the Job Name
                \s+J[0-9]{7}:\s+
                ', $this->getResultVar('FullMessage'), $atmp);

有没有办法将以上形式的正则表达式传递给preg_match?

EN

回答 2

Stack Overflow用户

发布于 2018-05-03 15:33:29

代码语言:txt
复制
preg_match("/
    test
/x", $foo, $bar);
票数 0
EN

Stack Overflow用户

发布于 2018-05-03 16:56:26

代码语言:txt
复制
preg_match('/
              ^J[0-9]{7}:\s+
              (.*?)             #Extract the Transaction Start Date msg
              \s+J[0-9]{7}:\s+Project\sname:\s+
              (.*?)             #Extract the Project Name
              \s+J[0-9]{7}:\s+Job\sname:\s+
              (.*?)             #Extract the Job Name
              \s+J[0-9]{7}:\s+
            /x', $this->getResultVar('FullMessage'), $atmp);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100001555

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档