简体   繁体   English

PHP中的正则表达式,提取标记之间的字符串并将其替换

[英]Regular Expression in php, extracting string between tags and replace it

I have the following HTML and what I want is to extract the string between two tags and replace another string with the one that was extracted. 我有以下HTML,我想要提取两个标签之间的字符串,然后用提取的字符串替换另一个字符串。 Here is an example: 这是一个例子:

<p>|something=to remember:yes: no</p>
<p><A:keyword term="to remember, yes no" /></p>

I have built something like this but I do not know whether regular expressions really help me here? 我已经建立了类似的东西,但是我不知道正则表达式是否真的对我有帮助?

<[p]\>(.*)<\/p>

Thanks for your help. 谢谢你的帮助。 I solved my problem by using 我通过使用解决了我的问题

something==([A-Za-z]*)\s([A-Za-z]*),\s([A-Za-z]*)\s([A-Za-z]*)

as a static input and then everything after it was treated with regex and grouping. 作为静态输入,然后用正则表达式和分组对其进行处理。 With that solution I did solve my problem. 通过这种解决方案,我确实解决了我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM