You are here: Re: pattern matching « PHP Programming Language « IT news, forums, messages
Re: pattern matching

Posted by ofuuzo1 on 12/03/07 08:14

On 1 Des, 03:10, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
> On Sat, 01 Dec 2007 01:03:07 +0100, <ofuu...@yahoo.no> 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
>
> > <?xml version="1.0" encoding="utf-8" standalone="no" ?>
> > <dublin_core schema="dc">
> > <dcvalue element="contributor" qualifier="advisor">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>
> > <dcvalue element="date" qualifier="issued">2007-11-15</dcvalue>
> > <dcvalue element="format" qualifier="extent">4869077 bytes</
> > dcvalue>
> > <dcvalue element="format" qualifier="mimetype">application/pdf</
> > dcvalue>
> > <dcvalue element="language" qualifier="iso">nob</dcvalue>
> > <dcvalue element="subject" qualifier="courseID">NOR-3920</dcvalue>
> > <dcvalue element="subject" qualifier="departmentID">6640</dcvalue>
> > </dublin_core>
>
> 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: <http://www.php.net/domxml>
>
> 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:

<dcvalue element="format" qualifier="extent">4869077 bytes</dcvalue>
<dcvalue element="language" qualifier="iso">nob</dcvalue>
<dcvalue element="subject" qualifier="courseID">NOR-3920</dcvalue>
<dcvalue element="subject" qualifier="departmentID">6640</dcvalue>

Thanks
Ofuuzo

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация