Preg Replace

Preg Replace

am 12.04.2008 20:36:25 von brunormbarros

I have a file with 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.

Re: Preg Replace

am 13.04.2008 08:59:12 von Albert Nick

On 4ÔÂ13ÈÕ, ÉÏÎç2ʱ36·Ö, Bruno Rafael Moreira de Bar=
ros
wrote:
> I have a file with > 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?

Re: Preg Replace

am 14.04.2008 00:54:36 von Alexey Kulentsov

Bruno Rafael Moreira de Barros wrote:
> I have a file with > 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('/]*>/i','',$with_meta);

Re: Preg Replace

am 18.04.2008 05:55:58 von Tim Roberts

Alexey Kulentsov wrote:

>Bruno Rafael Moreira de Barros wrote:
>> I have a file with >> 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('/]*>/i','',$with_meta);





Whoops...
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Re: Preg Replace

am 18.04.2008 10:36:27 von Alexey Kulentsov

Tim Roberts wrote:
> Alexey Kulentsov wrote:
>
>> Bruno Rafael Moreira de Barros wrote:
>>> I have a file with >>> 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('/]*>/i','',$with_meta);
>
>
>
>
>
> Whoops...
Incorrect HTML.
Here must be

Re: Preg Replace

am 18.04.2008 10:45:36 von luiheidsgoeroe

On Fri, 18 Apr 2008 10:36:27 +0200, Alexey Kulentsov wro=
te:

> Tim Roberts wrote:
>> Alexey Kulentsov wrote:
>>
>>> Bruno Rafael Moreira de Barros wrote:
>>>> I have a file with >>>> 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 s=
o.
>>>>
>>>> Thanks in advance.
>>> $without_meta=3Dpreg_replace('/]*>/i','',$with_meta);
>>
>>
>> ta=
g">
>> Whoops...
> Incorrect HTML.
> Here must be t; =

> tag">

Indeed, and how many sites have incorrect HTML? A lot more then fully =

valid ones... Which is why I'm going te repeat the mantra: "Use a parser=
=

for HTML manipulation or inspectation, not Regex". DOM comes to mind, ve=
ry =

nice package.
-- =

Rik Wasmus

Re: Preg Replace

am 19.04.2008 01:49:33 von Alexey Kulentsov

Rik Wasmus wrote:

> Indeed, and how many sites have incorrect HTML? A lot more then fully
> valid ones... Which is why I'm going te repeat the mantra: "Use a parser
> for HTML manipulation or inspectation, not Regex". DOM comes to mind,
> very nice package.

I think I am in big trouble: sometimes I use Regex-based parser, for
HTML too. :) I know about problem with incorrect attributes and can
write regexp to deal with it. Yes, this is much more easy to load file
into DOM document using loadHTML() then to write complex regexp dealing
with all these incorrect cases.

Re: Preg Replace

am 19.04.2008 11:59:51 von John Dunlop

Alexey Kulentsov:

> Tim Roberts wrote:
>
> >
>
> Incorrect HTML.

No it isn't.

(Yet *another* reason not to reinvent this particular wheel.)

--
Jock