Preg替换 [英] Preg Replace
本文介绍了Preg替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的文件包含< html>< head>< meta something ...>< meta something
else ...>。我需要删除该文本。
我会使用str_ireplace,但两个元素的内容会随文件一起更改
。
我知道preg_replace允许你这样做,但是如何?我曾试图学习正则表达式,但我遇到了严重的问题。
提前致谢。
解决方案
On 4 ??13è?,é???2ê±36·?, Bruno Rafael Moreira de Barros
< brunormbar ... @ gmail .comwrote:
我的文件包含< html>< head>< meta something ...>< meta something
else ...>。我需要删除该文本。
我会使用str_ireplace,但两个元素的内容会随文件一起更改
。
我知道preg_replace允许你这样做,但是如何?我曾尝试过
学习正则表达式,但我遇到了严重的问题。
提前致谢。
你想要做的只是删除HTML标签?
Bruno Rafael Moreira de Barros写道:
我的文件包含< html>< head>< meta something ...>< meta something
else ...取代。我需要删除该文本。
我会使用str_ireplace,但两个元素的内容会随文件一起更改
。
我知道preg_replace允许你这样做,但是如何?我曾尝试过
学习正则表达式,但我遇到了严重的问题。
提前致谢。
without_meta = preg_replace(''/< meta [^>] *> / i'','''',
I have a file with <html><head><meta something...><meta something
else...>. I need to remove that text.
I would use str_ireplace, but the contents of the two metas change
with the file.
I know preg_replace allows you to do that, but how? I have tried to
learn regular expressions, but I am having serious problems doing so.
Thanks in advance.
解决方案
On 4??13è?, é???2ê±36·?, Bruno Rafael Moreira de Barros
<brunormbar...@gmail.comwrote:I have a file with <html><head><meta something...><meta something
else...>. I need to remove that text.
I would use str_ireplace, but the contents of the two metas change
with the file.
I know preg_replace allows you to do that, but how? I have tried to
learn regular expressions, but I am having serious problems doing so.
Thanks in advance.What you want to do is just removing HTML tags?
Bruno Rafael Moreira de Barros wrote:I have a file with <html><head><meta something...><meta something
else...>. I need to remove that text.
I would use str_ireplace, but the contents of the two metas change
with the file.
I know preg_replace allows you to do that, but how? I have tried to
learn regular expressions, but I am having serious problems doing so.
Thanks in advance.
without_meta=preg_replace(''/<meta[^>]*>/i'','''',
这篇关于Preg替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文