RE: What exactly is this simple regex doing?
From: B. Fongo (perl_at_fongo.de)
Date: 04/16/04
- Next message: Wiggins D Anconia: "RE: What exactly is this simple regex doing?"
- Previous message: Paul D. Kraus: "Re: RTF::TEXT::Converter"
- In reply to: Wiggins D Anconia: "Re: What exactly is this simple regex doing?"
- Next in thread: Wiggins D Anconia: "RE: What exactly is this simple regex doing?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: "'Wiggins d Anconia'" <wiggins@danconia.org>, <beginners@perl.org> Date: Fri, 16 Apr 2004 18:20:54 +0200
Thanks for the small tutorial - but I must admit that I can only see
(according to your explanation) the regex to be matching anything except
a dot. So substituting them should return only 1 or more dots. But that
isn't what we get here. You're by saying that the dot in a class is not
a special qualifier.
Oh! How I wish I could understand it. :-) I think I need to go back to
learn some more regexs.
||> -----Original Message-----
||> From: Wiggins d Anconia [mailto:wiggins@danconia.org]
||> Sent: Friday, April 16, 2004 5:40 PM
||> To: B. Fongo; beginners@perl.org
||> Subject: Re: What exactly is this simple regex doing?
||>
||> Please bottom post....
||>
||> >
||> > This regex by Rob is working alright, but can't follow exactly how
it
||> > truncates an absolute url from first character to the one before
the
||> > dot.
||> >
||> > It returns (.domain4you.com from http:://www. domain4you.com.)
exactly
||> > what is expected, but I can't easily understand it.
||> >
||> > Please I'm not pulling anyone's leg. So just explain it if you
can.
||> >
||> > (.domain4you.com from http:://www. domain4you.com.)
||> >
||> >
||> > foreach (@domains) {
||> > my $name = $_;
||> > $name =~ s/^[^\.]+//;
||> > print $name;
||> > }
||>
||> The initial ^ says to start matching at the beginning of the string.
||>
||> [] defines a character class, so we are going to match against
||> characters in the class.
||>
||> In this case the ^ *because it is the first character* of the class
||> causes the class to be negated, aka we are going to match any
character
||> *not* in the class. The class is a \ and a . though I suspect that
||> should just be a . because I believe dot inside a class is not
special.
||>
||> The + says one or more of the characters matched by the class.
||>
||> So it is really saying match one or more characters that are not a
dot
||> starting at the beginning of the string. Or, match everything up
until
||> the first dot.
||>
||> http://danconia.org
- Next message: Wiggins D Anconia: "RE: What exactly is this simple regex doing?"
- Previous message: Paul D. Kraus: "Re: RTF::TEXT::Converter"
- In reply to: Wiggins D Anconia: "Re: What exactly is this simple regex doing?"
- Next in thread: Wiggins D Anconia: "RE: What exactly is this simple regex doing?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|