Bishork
asked on
Regular expressions help - how to disallow two characters to be next to one another
email validation checker -
I have
/^[a-z0-9]{1,}([a-z0-9_-]| \.(?!\.))+ @[a-z0-9]{ 1,}([a-z0- 9]|\.(?!\. )|\-(?!\-) ){1,}[a-z0 -9]+\.[a-z 0-9]{2,6}$ /i;
I want to disallow joe@j-.-d.com or joe@j.-.d.com
and make this validator even better
thanks
I have
/^[a-z0-9]{1,}([a-z0-9_-]|
I want to disallow joe@j-.-d.com or joe@j.-.d.com
and make this validator even better
thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sorry for the lack of explanation.
The function looks at all the entries in the array, and checks each one for a match within the target string. When it finds a sequence that exists in the target string, it stops looking and returns a boolean answer..
false = no matches
true = has a disallowed sequence
The function looks at all the entries in the array, and checks each one for a match within the target string. When it finds a sequence that exists in the target string, it stops looking and returns a boolean answer..
false = no matches
true = has a disallowed sequence
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hey Roba,
Ok that makes sense now.
Now I have
/^[a-z0-9]+([a-z0-9]|[._-] (?![._-])) +@[a-z0-9] {1}([a-z0- 9]|[-](?![ .-])){1}([ a-z0-9]|[. -](?![.-]) )+\.[a-z0- 9]{2,6}$/i
I wanted to make it so you could not have joe@j.com, joe@j-.com, joe@joe-.com. I used {1} to make the first two sets after the @ sign be for the first two characters you put in, then it can start accepting both periods and dashes.
You can still pass through a jeo@e-d.e.e.e.e.com
Is there a way I can limit the number of periods allowed in the domain, before the .xxx. I think you should only be able to have 1 right? joe@joe.ir.com, or maybe 2 (can you have jack@john.co.ur.com
Thanks
Ok that makes sense now.
Now I have
/^[a-z0-9]+([a-z0-9]|[._-]
I wanted to make it so you could not have joe@j.com, joe@j-.com, joe@joe-.com. I used {1} to make the first two sets after the @ sign be for the first two characters you put in, then it can start accepting both periods and dashes.
You can still pass through a jeo@e-d.e.e.e.e.com
Is there a way I can limit the number of periods allowed in the domain, before the .xxx. I think you should only be able to have 1 right? joe@joe.ir.com, or maybe 2 (can you have jack@john.co.ur.com
Thanks
ASKER
hmm but now with what i just pasted above, test@ab.com doesn't work
ASKER
ok i guess i want to make sure i say that, you have to have 1 character from a-z 0-9 after the @ sign, then after that you can only have a period if you have at least 2 chars from a-z 0-9, but the problem i run into is that you should be able to have a hyphen after only having 1 character from a-z 0-9
joe@f-f.com is ok, joe@j.com is not ok
joe@f-f.com is ok, joe@j.com is not ok
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I think I finally got it w/ /^[a-z0-9](([_\.\-]?[a-z0- 9]+)*)@([a -z0-9])+([ \-]?[a-z0- 9]+)(([\.\ -]?[a-z0-9 ]+)*)\.([a -z]{2,})$/ i
now I want to create a regular expression that allows any character.
I want j$^^$j@j#$j.com to pass this test, basically allowing any character between the first and last letter in the local and domain portion.
/^[a-z0-9]+???????[a-z0-9] +@[a-z0-9] +?????.([a -z]{2,})
I am trying to have it pass a form test first, then if you fail this test you'll get a message saying your email is of invalid form, then if you pass this test i'll run the more comprehensive check and tell you that you cannot have invalid characters. (not my idea)
i posted a new question
now I want to create a regular expression that allows any character.
I want j$^^$j@j#$j.com to pass this test, basically allowing any character between the first and last letter in the local and domain portion.
/^[a-z0-9]+???????[a-z0-9]
I am trying to have it pass a form test first, then if you fail this test you'll get a message saying your email is of invalid form, then if you pass this test i'll run the more comprehensive check and tell you that you cannot have invalid characters. (not my idea)
i posted a new question
ASKER
^[A-Za-z0-9](([_\.\-]?[a-z
online which does not allow -. and .- together but I'm not sure why or how to integrate it into my own
any help would be appreciated. thanks!