该数据的最佳优化预浸料图案是什么?需要正则表达式帮助
我需要 php preg 模式的帮助来从以下数据中提取内容:
<div class="box">
<div>
<a href="/;s=-w3NKGFjkswdkjbg0B;detail=person;id=937382/me">
<b>Smith, Johnny</b>
</a>
</div>
<div>
<a href="/;s=-w3NKGFjkswdkjbg0B/http%3aservice.myxyz.net/ch/cgi/g.fcgi/me/new?CUSTOMERNO=836327973&t=i373u.1310541179.a1ecb28b&[email protected]">[email protected]</a>
</div>
<div>
<a href="/;s=-w3NKGFjkswdkjbg0B;edit=person;id=937382/me"><img src="/;m=is;f=gif89a;h=18;k=sdakjdk12eksack;w=18/it%3amfitmcsfe19/DiEDzr48XbZcjfyGLMKnzw.gif" alt="" width="18" height="18">
</a>
<a href="/;s=-w3NKGFjkswdkjbg0B;delete=person;id=937382/me">
<img src="/;m=is;f=gif89a;h=18;k=Dk3k-kVox-ads9Lopt-yBQ;w=18/it%3amfitmcsfe19/tHJTBPhousrElDf1x5aPvA.gif" alt="" width="18" height="18">
</a>
</div>
<div class="fitMlModuleLinec8fe6cf8"> </div>
<div>
<a href="/;s=-w3NKGFjk4jkedkds8g0B;detail=person;id=327843287/me"></a>
</div>
<div>
<a href="/;s=-w3NKGFjk4jkedkds8g0B/http%3aservice.myxyz.net/ch/cgi/g.fcgi/me/new?CUSTOMERNO=98324826438&t=de13929382.1310541179.a1ecb28b&[email protected]">[email protected]</a>
</div>
<div>
<a href="/;s=-w3NKGFjk4jkedkds8g0B;edit=person;id=327843287/me">
<img src="/;m=is;f=gif89a;h=18;k=cBoj9wS5Yp5345435EREg;w=18/it%3amfitmcsfe19/DiEDzr48XbZcjfyGLMKnzw.gif" alt="" width="18" height="18"></a> |
<a href="/;s=-w3NKGFjk4jkedkds8g0B;delete=person;id=327843287/me">
<img src="/;m=is;f=gif89a;h=18;k=Dk3k-kVox-ads9Lopt-yBQ;w=18/it%3amfitmcsfe19/tHJTBPhousrElDf1x5aPvA.gif" alt="" width="18" height="18"></a>
</div>
<div class="fitMlModuleLinec8fe6cf8"> </div>
<div>
<a href="/;s=-w3NKGsndqw21g0B;detail=person;id=83467836/me">
<b>Parker</b>
</a>
</div>
<div>
<a href="/;s=-w3NKGsndqw21g0B;edit=person;id=83467836/me">
<img src="/;m=is;f=gif89a;h=18;k=cBodejksa23KNKvUEREg;w=18/it%3amfitmcsfe19/DiEDzr48XbZcjfyGLMKnzw.gif" alt="" width="18" height="18"></a> |
<a href="/;s=-w3NKGF6hSNhymOcg6uWbg0B;delete=person;id=83467836/me">
<img src="/;m=is;f=gif89a;h=18;k=Dk3k-kVox-ads9Lopt-yBQ;w=18/it%3amfitmcsfe19/tHJTBPhousrElDf1x5aPvA.gif" alt="" width="18" height="18"></a>
</div>
<div class="fitMlModuleLinec8fe6cf8"> </div>
</div>
</div>
上面的数据如下所示:
以下是条件:
- 我想提取电子邮件地址。
- 如果找到电子邮件地址,则检查姓名。如果找到姓名,则检查姓名 获取该电子邮件地址的人员姓名。
- 如果找到姓名并且未指定该人的电子邮件地址 然后丢弃数据。
输出数组应如下所示:
Array(
[email#1]= array([name]='name'),
[email#2]= array([name]='name')
.
.
[email#n]= array([name]='name')
)
上述数据的结果应如下所示:
Array(
[[email protected]]= array([name]='Smith, Johnny'),
[[email protected]]= array([name]='')
)
请为我建议针对上述问题的最高优化的 preg_match
。
I need help with php preg pattern to extract contents from the following data :
<div class="box">
<div>
<a href="/;s=-w3NKGFjkswdkjbg0B;detail=person;id=937382/me">
<b>Smith, Johnny</b>
</a>
</div>
<div>
<a href="/;s=-w3NKGFjkswdkjbg0B/http%3aservice.myxyz.net/ch/cgi/g.fcgi/me/new?CUSTOMERNO=836327973&t=i373u.1310541179.a1ecb28b&[email protected]">[email protected]</a>
</div>
<div>
<a href="/;s=-w3NKGFjkswdkjbg0B;edit=person;id=937382/me"><img src="/;m=is;f=gif89a;h=18;k=sdakjdk12eksack;w=18/it%3amfitmcsfe19/DiEDzr48XbZcjfyGLMKnzw.gif" alt="" width="18" height="18">
</a>
<a href="/;s=-w3NKGFjkswdkjbg0B;delete=person;id=937382/me">
<img src="/;m=is;f=gif89a;h=18;k=Dk3k-kVox-ads9Lopt-yBQ;w=18/it%3amfitmcsfe19/tHJTBPhousrElDf1x5aPvA.gif" alt="" width="18" height="18">
</a>
</div>
<div class="fitMlModuleLinec8fe6cf8"> </div>
<div>
<a href="/;s=-w3NKGFjk4jkedkds8g0B;detail=person;id=327843287/me"></a>
</div>
<div>
<a href="/;s=-w3NKGFjk4jkedkds8g0B/http%3aservice.myxyz.net/ch/cgi/g.fcgi/me/new?CUSTOMERNO=98324826438&t=de13929382.1310541179.a1ecb28b&[email protected]">[email protected]</a>
</div>
<div>
<a href="/;s=-w3NKGFjk4jkedkds8g0B;edit=person;id=327843287/me">
<img src="/;m=is;f=gif89a;h=18;k=cBoj9wS5Yp5345435EREg;w=18/it%3amfitmcsfe19/DiEDzr48XbZcjfyGLMKnzw.gif" alt="" width="18" height="18"></a> |
<a href="/;s=-w3NKGFjk4jkedkds8g0B;delete=person;id=327843287/me">
<img src="/;m=is;f=gif89a;h=18;k=Dk3k-kVox-ads9Lopt-yBQ;w=18/it%3amfitmcsfe19/tHJTBPhousrElDf1x5aPvA.gif" alt="" width="18" height="18"></a>
</div>
<div class="fitMlModuleLinec8fe6cf8"> </div>
<div>
<a href="/;s=-w3NKGsndqw21g0B;detail=person;id=83467836/me">
<b>Parker</b>
</a>
</div>
<div>
<a href="/;s=-w3NKGsndqw21g0B;edit=person;id=83467836/me">
<img src="/;m=is;f=gif89a;h=18;k=cBodejksa23KNKvUEREg;w=18/it%3amfitmcsfe19/DiEDzr48XbZcjfyGLMKnzw.gif" alt="" width="18" height="18"></a> |
<a href="/;s=-w3NKGF6hSNhymOcg6uWbg0B;delete=person;id=83467836/me">
<img src="/;m=is;f=gif89a;h=18;k=Dk3k-kVox-ads9Lopt-yBQ;w=18/it%3amfitmcsfe19/tHJTBPhousrElDf1x5aPvA.gif" alt="" width="18" height="18"></a>
</div>
<div class="fitMlModuleLinec8fe6cf8"> </div>
</div>
</div>
The above data looks like this :
Following are the conditions :
- I want to extract email addresses.
- If email address is found then check for name.. if name found then
fetch name of the person for that email address. - If name is found and no email address for that person is specified
then discard the data.
The output array should look like :
Array(
[email#1]= array([name]='name'),
[email#2]= array([name]='name')
.
.
[email#n]= array([name]='name')
)
The result from above data should look like :
Array(
[[email protected]]= array([name]='Smith, Johnny'),
[[email protected]]= array([name]='')
)
Kindly suggest me the highest optimized preg_match
for above problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我正在对您的数据质量做出一些假设,但您可以
这有点粗糙,但如果您可以保证
href
不包含"
(这应该被扩展为"
),然后它将提取电子邮件。I'm making some assumptions about the quality of your data, but you could
This is a bit crude but if you can guarantee the
href
doesn't contain"
(which should be excaped to"
) then it will extract the e-mail.