Article View: es.comp.os.linux.programacion
Article #8206Re: Problemilla con expresiones regulares
From: Angel Luis JimĂ©nez MartĂnez
Date: Sun, 29 Dec 2002 01:18
Date: Sun, 29 Dec 2002 01:18
33 lines
2250 bytes
2250 bytes
Saiyine <saiyine@clubdelphi.com> wrote:
> Saiyine dijo el otro dia que ...
>> Por fin, esta es la expresion regular que buscaba:
>>
>> <info>([^(info)]*)<\/info>
>>
>> El truco era negar la palabra metida entre parentesis, para que piense que
>> es un solo caracter.
> Pues no. Solo funcionaba porque daba la casualidad de que no habia ninguna
> de las letras i - n - f - o entre los datos :(
> Me rindo... por ahora!
Pera, que aun queda mecha XDDD
$cad= "<info>prueba1234<kk>delavaca</kk></info><info>blablablabla</info>";
$cad=~ s/<info>(.*?)<\/info>.*/$1/;
print "$cad\n";
El (.*?) lo he sacado de la pagina del perlre
http://www.perldoc.com/perl5.6.1/pod/perlre.html#Backtracking
Copy-paste:
Here it's more effective to use minimal matching to make sure you get the
text between a "foo" and the first "bar" thereafter.
if ( /foo(.*?)bar/ ) { print "got <$1>\n" }
got <d is under the >
A ver que tal te va :D
Technical Details
Message-ID:
<auliha$eja$1@sofora02.uji.es>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.wirehub.nl!news.astraweb.com!news-small.astraweb.com!news-out.spamkiller.net!propagator2-maxim!news-in.spamkiller.net!news.telia-iberia.com!news.rediris.es!news.uv.es!sofora01.uji.es!not-for-mailReferences:
<aui8bh$7ha23$1@ID-84570.news.dfncis.de> <auisj8$7ps2h$1@ID-84570.news.dfncis.de> <auiuu4$7kpc7$1@ID-84570.news.dfncis.de>Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII-7-bit
X-Google-Thread: f86c8,421d9d514e364efa
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2002-12-28 17:28:10 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.wirehub.nl!news.astraweb.com!news-small.astraweb.com!news-out.spamkiller.net!propagator2-maxim!news-in.spamkiller.net!news.telia-iberia.com!news.rediris.es!news.uv.es!sofora01.uji.es!not-for-mail
From: Angel Luis JimĂ©nez MartĂnez <al026635@alumail.uji.es>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: Problemilla con expresiones regulares
Date: Sun, 29 Dec 2002 01:18:34 +0000 (UTC)
Organization: Universitat Jaume I
Lines: 33
Sender: Angel Luis JimĂ©nez MartĂnez <al026635@anubis.uji.es>
Message-ID: <auliha$eja$1@sofora02.uji.es>
References: <aui8bh$7ha23$1@ID-84570.news.dfncis.de> <auisj8$7ps2h$1@ID-84570.news.dfncis.de> <auiuu4$7kpc7$1@ID-84570.news.dfncis.de>
NNTP-Posting-Host: anubis.uji.es
X-Trace: sofora02.uji.es 1041124714 14954 150.128.40.100 (29 Dec 2002 01:18:34 GMT)
X-Complaints-To: news@marti.uji.es
NNTP-Posting-Date: Sun, 29 Dec 2002 01:18:34 +0000 (UTC)
User-Agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (AIX/4-3)