List Info

Thread: What's wrong with this expression?




What's wrong with this expression?
user name
2006-02-21 04:13:11
Hi,
    I am quite a newbie in the magnificent world of Regular
Expressions
but I'm already hooked! Can someone please suggest t me
what's wrong
with this regex?

$ egrep -i 'www(\.[a-z][a-z0-9])+\.[a-z]+' testfile

where testfile contains various URLs such as

www.rootshell.be/~timmy
www.google.com
www.bartleby.cs.edu.com/YahooGoogleMicrosoft, etc.

I am using egrep version 2.5.1 in Red Hat Linux.

Regards,

Timmy Jose.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---

What's wrong with this expression?
user name
2006-02-21 04:24:56
"ZOLTAN" <zoltan.josegmail.com> wrote:
>
>
>Hi,
>    I am quite a newbie in the magnificent world of
Regular Expressions
>but I'm already hooked! Can someone please suggest t me
what's wrong
>with this regex?

In this case, your problem is that you don't have a
quantifier after that
last character class before the closed parenthesis, so it's
only looking
for 2 characters after the dot.

www(\.[a-z][a-z0-9]+)+\.[a-z]+

That simple change and it will match all the domains, but
naturally nothing
after.

See her in action: http://tinyurl.com/eb7r5

Allen

-- 
Remember, no matter where you go, there you are. -Buckaroo
Banzai
Online Regex find/repalce utility: http://rereplace.com
Command-based online image editor: http://theprawn.com/imag
iine

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )