[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: regex question
- To: luci-discuss@luci.org
- Subject: Re: regex question
- From: Danny Sauer <sauer@cloudmaster.com>
- Date: Tue, 3 Jul 2001 13:59:37 -0500
- In-Reply-To: <Pine.LNX.4.33.0106270928160.27277-100000@ns1.lunarmedia.net>; from charles@lunarmedia.net on Wed, Jun 27, 2001 at 09:51:03AM -0500
- Organization: Linux Users of Central Illinois
- References: <Pine.LNX.4.33.0106270928160.27277-100000@ns1.lunarmedia.net>
- Reply-To: luci-discuss@luci.org
- Sender: owner-luci-discuss@luci.org
On Wed, Jun 27, 2001 at 09:51:03AM -0500, charles@lunarmedia.net wrote:
> i'd like to test to see if a variable has two \@ symbols, and i am
> struggling with the best way to do so. i am sure the format of the string
> will be
>
> foo@bar.com foo@baz.com
>
> where the empty space between the two addresses could be any one or two
> characters. so far, i have come up with
>
> /^(\w)+\@(\w)+\.(\w)+(.|..)(\w)+/@/
>
> but i am not certain if this is very efficient. i only test up to the
> second @ in my regex which i think is sufficient to verify whether or not
> the string has two @ symbols
Couldn't you use something like this:
/^(\w+\@\w+(\.\w+)+\s*){2}/
It *does* work, but I wouldn't swear to any increased efficiency...
echo "moo@moo.com sheep.net" | perl -nle'print if(/^(\w+\@\w+(\.\w+)+\s*){2}/);'
echo "moo@moo.com bah@sheep.net" | perl -nle'print if(/^(\w+\@\w+(\.\w+)+\s*){2}/);'
--Danny, who always screws up regex's on the first try, for some reason :)
-
To unsubscribe, send email to majordomo@luci.org with
"unsubscribe luci-discuss" in the body.