From: Kevin Walzer on
Hello all,

I'm trying to create a regex to match Twitter usenames (@username): I
also need this regex to exclude e-mail addresses.

I'm using this regex currently:

{@([A-Za-z0-9_]+)}

which matches the following:

@foo

@foo: LOL u r gr8

bar(a)foo.com

I want to match the first two, but not the third. Any advice?

--Kevin

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
From: Andreas Leitgeb on
Kevin Walzer <kw(a)codebykevin.com> wrote:
> I'm using this regex currently:
> {@([A-Za-z0-9_]+)}
> @foo
> @foo: LOL u r gr8
> bar(a)foo.com
> I want to match the first two, but not the third. Any advice?

use: {^@([A-Za-z0-9_]+)}
From: Gerald W. Lester on
Kevin Walzer wrote:
> Hello all,
>
> I'm trying to create a regex to match Twitter usenames (@username): I
> also need this regex to exclude e-mail addresses.
>
> I'm using this regex currently:
>
> {@([A-Za-z0-9_]+)}
>
> which matches the following:
>
> @foo
>
> @foo: LOL u r gr8
>
> bar(a)foo.com
>
> I want to match the first two, but not the third. Any advice?

I'd not use regex but rather: string match -nocase {@*} $testCase

I think it is much more readable.

--
+------------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email: Gerald.Lester(a)kng-consulting.net |
+------------------------------------------------------------------------+