Re: extracting substrings from string using regexp
- From: rcook@xxxxxxxxxxx (Owen Cook)
- Date: Tue, 13 Dec 2005 09:18:04 +1100 (EST)
On Mon, 12 Dec 2005, Xavier Noria wrote:
> On Dec 12, 2005, at 22:10, Owen wrote:
>
> > Xavier Noria wrote:
> >> On Dec 12, 2005, at 11:10, Alexandre Checinski wrote:
> >
> >>> I have a string that looks like this :
> >>> <counter id="183268" since="SDOPERFV16" aggr="Sum"
> >>> name="pcmTcuFaultOutOfService"/>
> >
> >>
> >> m// in list contex may help:
> >>
> >> my ($id, $name) = $xml =~ m{id="([^"]*)".*name="([^"]*)"/>};
> The answer is short, but since you already did this effort I'll tell
> you a way to figure out what's missing that's very close to your
> approach: Ask japhy's YAPE::Regex::Explain about it:
>
> use YAPE::Regex::Explain;
> print YAPE::Regex::Explain->new(qr{id="([^"]*)".*name="([^"]*)"/
> >})->explain;
Thank you for bring that module to my attention, it is truely
instructional.
It says of
[^"]* any character except: '"' (0 or more
times (matching the most amount possible))
So having now read the appropriate section in my Programming Perl, I
see "A caret in front of a list causes it match only characters that are
NOT in the list"
Thank you
Owen
.
- Prev by Date: RE: sort files by creation time
- Next by Date: Re: sort files by creation time
- Previous by thread: Re: extracting substrings from string using regexp
- Next by thread: RE: extracting substrings from string using regexp
- Index(es):