Re: [pcre-dev] pcre problem

Top Page
Delete this message
Author: Thorsten Schöning
Date:  
To: pcre-dev
Subject: Re: [pcre-dev] pcre problem
Guten Tag fuzzy_4711,
am Samstag, 15. Januar 2011 um 00:46 schrieben Sie:

> $stringToParse = '<TFS901>Abama Golf</TFS901><AUH901>Abu Dhabi
> Golf</AUH901><PMI901>Alcanada Golf</PMI901><AGP901>Alferini
> Golf</AGP901><AGP902>Almenara Golf</AGP902>';



> $LookFor = '/<(.+)([^>]|\n)*>((.|\s)*?)<\/\1(\\s)*>/i';


I tested the string and regexp with QuickREx and it matched
"<TFS901>Abama Golf</TFS901>" and extracted "TFS901" as the first
capture group. Maybe your problem is that preg_match_all needs a full
match to return true? What happens with the following? I suggest it
will return true.

$LookFor = '/<(.+)([^>]|\n)*>((.|\s)*?)<\/\1(\\s)*>.*/i';

In general, parsing XML with regular expressions is often a pretty bad
idea because if the XML gets more complex you have to rebuild all the
logic a XML parser already provides.

Mit freundlichen Grüßen,

Thorsten Schöning

--
Thorsten Schöning
AM-SoFT IT-Systeme - Hameln | Potsdam | Leipzig

Telefon: Potsdam: 0331-743881-0
E-Mail:  tschoening@???
Web:     http://www.am-soft.de


AM-SoFT GmbH IT-Systeme, Konsumhof 1-5, 14482 Potsdam
Amtsgericht Potsdam HRB 21278 P, Geschäftsführer: Andreas Muchow