pattern matching

pattern matching

am 01.12.2007 01:03:07 von ofuuzo1

Hi,
I am new to php. I have text files each containing some metadata. I
would like to use preg_replace to remove some of the fields in each
text file. Some contents of a field can go over several lines. How can
I do it using preg_replace?

Thanks in advance
Ofuuzo



Test, Testman
several lines several lines several lines several lines several
lines several lines several lines several lines several lines
several lines several lines several lines several lines dcvalue>
2007-11-15
4869077 bytes dcvalue>
application/pdf dcvalue>
nob
NOR-3920
6640

Re: pattern matching

am 01.12.2007 03:10:33 von luiheidsgoeroe

On Sat, 01 Dec 2007 01:03:07 +0100, wrote:

> Hi,
> I am new to php. I have text files each containing some metadata. I
> would like to use preg_replace to remove some of the fields in each
> text file. Some contents of a field can go over several lines. How can=

> I do it using preg_replace?
>
> Thanks in advance
> Ofuuzo
>
>
>
> Test, Testman=

> several lines several lines several lines several lines several
> lines several lines several lines several lines several lines
> several lines several lines several lines several lines > dcvalue>
> 2007-11-15
> 4869077 bytes > dcvalue>
> application/pdf
> dcvalue>
> nob
> NOR-3920 e>
> 6640 e>
>


This isn't just text, it's XML. You really get a benefit from using one =
of =

the several possibilities/extentions mentioned in the manual. DOMXML wou=
ld =

be my choice for this:

If you really want it using a regex (which is possible, but inflexible a=
nd =

cumbersome), please inform us which field you want the have removed.
-- =

Rik Wasmus

Re: pattern matching

am 03.12.2007 09:14:21 von ofuuzo1

On 1 Des, 03:10, "Rik Wasmus" wrote:
> On Sat, 01 Dec 2007 01:03:07 +0100, wrote:
> > Hi,
> > I am new to php. I have text files each containing some metadata. I
> > would like to use preg_replace to remove some of the fields in each
> > text file. Some contents of a field can go over several lines. How can
> > I do it using preg_replace?
>
> > Thanks in advance
> > Ofuuzo
>
> >
> >
> > Test, Testman
> > several lines several lines several lines several lines several
> > lines several lines several lines several lines several lines
> > several lines several lines several lines several lines > > dcvalue>
> > 2007-11-15
> > 4869077 bytes > > dcvalue>
> > application/pdf > > dcvalue>
> > nob
> > NOR-3920
> > 6640
> >

>
> This isn't just text, it's XML. You really get a benefit from using one of
> the several possibilities/extentions mentioned in the manual. DOMXML would
> be my choice for this:
>
> If you really want it using a regex (which is possible, but inflexible and
> cumbersome), please inform us which field you want the have removed.
> --
> Rik Wasmus

I would like to use a regex. I want to open the file, remove a fix
number of fields and its contents and store it back to the file.
Example, removing the following:

4869077 bytes
nob
NOR-3920
6640

Thanks
Ofuuzo

Re: pattern matching

am 03.12.2007 13:24:36 von AnrDaemon

Greetings, ofuuzo1@yahoo.no.
In reply to Your message dated Monday, December 3, 2007, 11:14:21,

>> > I am new to php. I have text files each containing some metadata. I
>> > would like to use preg_replace to remove some of the fields in each
>> > text file. Some contents of a field can go over several lines. How can
>> > I do it using preg_replace?
>>
>> >
>> >
>> > Test, Testman
>> > several lines several lines several lines several lines several
>> > lines several lines several lines several lines several lines
>> > several lines several lines several lines several lines >> > dcvalue>
>> > 2007-11-15
>> > 4869077 bytes >> > dcvalue>
>> > application/pdf >> > dcvalue>
>> > nob
>> > NOR-3920
>> > 6640
>> >

>>
>> This isn't just text, it's XML. You really get a benefit from using one of
>> the several possibilities/extentions mentioned in the manual. DOMXML would
>> be my choice for this:
>>
>> If you really want it using a regex (which is possible, but inflexible and
>> cumbersome), please inform us which field you want the have removed.

> I would like to use a regex. I want to open the file, remove a fix
> number of fields and its contents and store it back to the file.
> Example, removing the following:

> 4869077 bytes
> nob
> NOR-3920
> 6640

Rik was right, it is NOT a plain text for what RegEx is intended.
It IS XML document, so if You want to be right you should use XML functions to
deal with it. Of course, You MAY use RegEx on any type of strings (even
binary, but results are depends on Your knowledge).


--
Sincerely Yours, AnrDaemon