Help with Regex (UserName, Email)

R

rolinson

Hello!

Help with Regex, Thanks in avance!


1. Validation of Name

Enable ALL keys on keyboard EXCEPT 0, 1, 2........., 9
Change to uppercase of 1st alphabet of every word and lowercase for
the rest of the word.
Example: aDa AdA 12DDD 12ddd dd12dd ¨¤ Ada Ada 12Ddd 12Ddd Dd12dd


a) If Name (0-2 characters) < 3 characters, excluding spacing and
punctuations

OR

b) If Any Part of Name has 4 or more consecutive A-Z/0-9 in ascending
or descending order, excluding case sensitivity. (e.g. 6789, 9876,
wxYz, zyXw, Test2345ing, 122abcdZ444)

OR

c) If Name = 3 or more consecutive A-Z/0-9 in ascending or descending
order, excluding case sensitivity. (e.g. 678, 987, 6789, 9876, Wxy,
Yxw, wxYz, zyXw)

OR

d) If Name = ALL recurring characters, excluding spacing,
punctuations and case sensitivity
(e.g. @@@, AaAaaA, 99999, EE EEE EEEE, eE E;e'E Ee#eE)

OR

e) If Any Part of Name has 3 or more repeat sequence of 2 characters
excluding spacing and case sensitivity. (e.g. sasasa, dfdfdf,
MunununT, MunZUnuNT, a12e12p12, aAbATaBt edab, EaA GAa Raa)
ShowMessage: Please re-enter the Name again.

END



f) If Name at least 1 character = 0, 1, 2........., 9 (e.g. A9E, A99E,
A9E9, A9E-A99E, A9E-A99E)
ShowMessage: Only alphabets are allowed. Please re-enter the Name
again.

END



f) If Name at least 1 character = Foreign Characters (non-English
characters) (e.g. °Ù¶È, aÁõbµÂ»ªc, ¥¤¥Ù¥ó¥È, ¥¤a¥Ùb¥óc¥È)
ShowMessage: Our system currently only supports English
characters. Only alphabets are allowed. Please re-enter the Name
again.
END


-------------------------------------------------------------------
2. Validation of Email Address

a) If Email Address = Empty

ShowMessage: Please enter your email address.

END



b) If Email Address Invalid format.

OR

c) If Email Address = ALL recurring characters excluding punctuations
and case sensitivity.
(e.g. @@@@@.@@@, (e-mail address removed), [email protected])

ShowMessage: Please re-enter a valid email address again.

END


d) If Email Address at least 1 character = Foreign Characters (non-
English characters)
(e.g. °Ù¶È@aa¶Èss.com, aÁõµÂ»ª[email protected], ¥¤¥Ù¥ó¥È@aass.com, ¥¤a¥Ùb@a¥ó.com)

ShowMessage: Please re-enter a valid email address again.


E) If Your Email and Friend's Email Address is the same (e.g. Your
Email (e-mail address removed) and Friend's Email (e-mail address removed))

ShowMessage: Email must not be the same. Please re-enter a valid
email address again.

END
 
J

Jesse Houwing

I have a feeling you haven't tried regex till now, otherwise you would
have posted them with a question on how to make them work or what was
wrong with them. Generally the people who answer questions in this
newsgroup aren't too fond if you haven't tried for yourself. It would be
different if you would've asked if regex was the way to go. But then I'd
only have answered yes/no.

Next time, try to make an effort before asking.

Jesse

Answers below:

* (e-mail address removed) wrote, On 26-7-2007 4:09:
Hello!

Help with Regex, Thanks in avance!


1. Validation of Name

Enable ALL keys on keyboard EXCEPT 0, 1, 2........., 9
Change to uppercase of 1st alphabet of every word and lowercase for
the rest of the word.
Example: aDa AdA 12DDD 12ddd dd12dd ¨¤ Ada Ada 12Ddd 12Ddd Dd12dd

I don't understand this. First you say everything except numbers, your
sample string includes numbers.

a) If Name (0-2 characters) < 3 characters, excluding spacing and
punctuations

length of a string is easy:

^.{3,}$

forces at least 3 characters
OR

b) If Any Part of Name has 4 or more consecutive A-Z/0-9 in ascending
or descending order, excluding case sensitivity. (e.g. 6789, 9876,
wxYz, zyXw, Test2345ing, 122abcdZ444)

Cannot be done in regex.
OR

c) If Name = 3 or more consecutive A-Z/0-9 in ascending or descending
order, excluding case sensitivity. (e.g. 678, 987, 6789, 9876, Wxy,
Yxw, wxYz, zyXw)

Cannot be done in regex either.
OR

d) If Name = ALL recurring characters, excluding spacing,
punctuations and case sensitivity
(e.g. @@@, AaAaaA, 99999, EE EEE EEEE, eE E;e'E Ee#eE)

^\W*(\w)\W*\1\w*$

find a word character (letter or number) and try to fill the string with
just that character and other non-word characters (spacing, punctuation).
OR

e) If Any Part of Name has 3 or more repeat sequence of 2 characters
excluding spacing and case sensitivity. (e.g. sasasa, dfdfdf,
MunununT, MunZUnuNT, a12e12p12, aAbATaBt edab, EaA GAa Raa)
ShowMessage: Please re-enter the Name again.

(\w)(?=(.*\1){2})

finds a character and tries to find at least two more of that character
further on in the string.

END

f) If Name at least 1 character = 0, 1, 2........., 9 (e.g. A9E, A99E,
A9E9, A9E-A99E, A9E-A99E)
ShowMessage: Only alphabets are allowed. Please re-enter the Name
again.

^[A-Za-z]+$

Make sure it only contains a letter in the alphabet. This conflicts with
earlier regexs which allow punctuation, whitespace and other stuff.
f) If Name at least 1 character = Foreign Characters (non-English
characters) (e.g. °Ù¶È, aÁõbµÂ»ªc, ¥¤¥Ù¥ó¥È, ¥¤a¥Ùb¥óc¥È)
ShowMessage: Our system currently only supports English
characters. Only alphabets are allowed. Please re-enter the Name
again.
END

Already enforced by the previous regex. You'd probably be better off
explaining which characters are allowed instead of tryign to exclude
every series that isn't.
-------------------------------------------------------------------
2. Validation of Email Address

a) If Email Address = Empty

ShowMessage: Please enter your email address.

END



b) If Email Address Invalid format.

OR

c) If Email Address = ALL recurring characters excluding punctuations
and case sensitivity.
(e.g. @@@@@.@@@, (e-mail address removed), [email protected])

ShowMessage: Please re-enter a valid email address again.

See above.
END

d) If Email Address at least 1 character = Foreign Characters (non-
English characters)
(e.g. °Ù¶È@aa¶Èss.com, aÁõµÂ»ª[email protected], ¥¤¥Ù¥ó¥È@aass.com, ¥¤a¥Ùb@a¥ó.com)

ShowMessage: Please re-enter a valid email address again.

See above
E) If Your Email and Friend's Email Address is the same (e.g. Your
Email (e-mail address removed) and Friend's Email (e-mail address removed))

ShowMessage: Email must not be the same. Please re-enter a valid
email address again.

END

Can't use regex for that.
 
Top