php - 正则表达式 php 中替代值的 Preg_match 不起作用
问题描述
我需要帮助。我不明白为什么它不起作用。我有以下html。(夫人=夫人,先生=先生)
Herr John Doe <br />
<br />
Frau Jane Smith <br />
我在我的 php 代码中使用 preg_match 遵循正则表达式。
preg_match_all("!<li class='default highlightProfilePremium'>(.*?)<\/li>!is", $result, $match);
for ($i=0;$i<count($match[1]);$i++){
if(preg_match("!Herr(.*\W)<br \/>|Frau(.*\W)<br \/>!",$match[1][$i], $contact)) {
$list['contact'][$i] = $contact[1];
} else {
$list['contact'][$i] = '';
};
}
在 regex101 中找到了这两个正则表达式。然而,在 php 中,他只能找到一个。我究竟做错了什么。谢谢你的帮助
解决方案
推荐阅读
- selenium - PageSource() 获取的代码与 appium 检查器代码不同
- python - 如何使用python有效地查找具有一定间隔的两个地理位置/位置之间的所有坐标
- python - 如何在熊猫数据框子集操作中将 end_time 指定为当前时间
- java - 请求范围的 Spring AOP 建议被调用两次
- php - 如何使用 ACF 复选框值进行 meta_query,因为它们将自己存储为数组?
- angular - 愚蠢的 UI 组件:如何在输出发出后应用条件行为
- angularjs - 如果数组中的对象缺少字段,如何隐藏元素
- python - 排序后如何获取数据帧的索引
- sql - 我想将数字更改为小时:分钟
- ajax - 字段中的值不会通过 ajax 传递给 php