[ale] [Fwd: Re: regexp, guru?]
JD
jdp at algoloma.com
Thu Nov 3 16:44:20 EDT 2011
On 11/03/2011 04:28 PM, Geoffrey Myers wrote:
> Can someone explain:
>
> ._%+- (first brackets)
> .- (second brackets)
>
>
> [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]
>
It looks like someone is trying to match email addresses.
The first [] is a list of all the characters allowed before the '@'.
Think of those as
- letters or
- numbers or
- _ or
- % or
- . or
- -
There must be at least 1 of those characters. That's what the trailing
'+' means after the close bracket, ].
The 2nd bracket says that the first character AFTER the '@' must be in
that list.
- letters or
- numbers or
- . or
- -
And I think is says 1 character (implied), but since there isn't a .$
the remaining characters in the line are ignored. This is not a
sufficient match for domain names, but I guess it works in a pinch.
I'd have to look up if the '-' in the brackets just before the closed
bracket, ']' was allowed. The '.' (periods) inside the brackets ARE
periods - they do not match "any character" like they would outside
brackets. I'm assuming regex with perl extensions - egrep, not grep syntax.
There is a javascript regex checker somewhere online. Can't recall where
now.
More information about the Ale
mailing list