doushang1964 2013-05-08 11:42
浏览 45
已采纳

PHP Regex匹配其他文件中的所有字符串

I have created one regex that can extract all string from PHP files. Example, I have "abc.php", I want to extract all string inside there (including tags " ' ). I make my own regex but some of string didn't match or overmatch.

Note : My intention also same with post here -> PHP: Regex to match the following string samples

But agent-j answers inside that thread also didn't match some of string.

Basically, this is my regex

/[\"|\'][^.\/\"](.*?)[^,\\][\"|\']/

Here the problem in picture..

enter image description here

enter image description here

enter image description here

enter image description here

I also try use agent-j regex, but his regex has problem when matching string in multiple line.

His regex

(['"])((?:\\\1|(?!\1).)+)\1

Problem with this regex

enter image description here

  • 写回答

2条回答 默认 最新

  • duanjiong5686 2013-05-09 07:19
    关注

    Look like anybody don't solve my problem. I solved this problem myself with help of my friend. So this is the regex that i was looking for.

    /([\"\'])(?:(?=(\\\\?))\\2.)*?\\1/s
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大