/    Sign up×
Community /Pin to ProfileBookmark

Hi,

Please tell me how to get start with regular expression, mean how to know rule and syntax of wriitng regular expression like this one

[COLOR=”Red”]exp = /^(([a-zA-Z0-9._]+)@(([a-zA-Z0-9_]+.)+)([a-z]{2,3})([,;]W?(?!$))?)+$/;[/COLOR]

I have to do it for multiple email address validation. It is working alright but there is one problem in it , when i write email address like this
[email][email protected]@go.com[/email]

It should return false, but it return true.
Can any one tell me how to do right it ?

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@scragarAug 16.2008 — <i>
</i>/ start/end of the regexp
^ start of the string
( ) enclosures, that's handy for grouping things
[ ] one of the characters/sets inside it
a-z A-Z 0-9 letters a to z, A to Z or numbers 0-9 respectively
- . literally the - or . respectively
+ 1 or more
{n, m} between n and m of the group
W any word character
? optional
* any number
$ end of string
that any good?
Copy linkTweet thisAlerts:
@RabidRickAug 16.2008 — I think if you get rid of the last "+" it will be fine (it looks like you're matching the whole main grouping multiple times)
Copy linkTweet thisAlerts:
@hoangkcAug 16.2008 — [code]
...
W any word character
...
[/QUOTE]

please tell me if I'm wrong.
As I know,
w Match a word character (alphanumeric characters and "_")
and
W Match a non-word character
Copy linkTweet thisAlerts:
@scragarAug 16.2008 — yeah, your right, same rule applies to d and D for digits, capitals are inverted.
Copy linkTweet thisAlerts:
@sayfrndshipauthorAug 22.2008 — Thnks !
×

Success!

Help @sayfrndship spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...