JS one (gulp) regular expression Q ...
Code:
var blnRegExpValidEMail = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
So here I am, just downloaded a working example of a JS e-mail validation code & pinching it's code to shove into my project :D
Thought it best to do some comments for once & explain what on Earth I'm trying to do incase I come back to it later, so I'm swamped under my javascript books here trying to make some sense of what the above's trying!
I've got :
- "/^[a-zA-Z0-9._-]" Is checking for any character apart from those in the square brackets.
- "+@" Checks that after the above characters have been removed, we've got 1 or more @ symbols in the string.
Why I've got brackets in the next bit, or the "+\" bit I'm not 100% on, I've found that the $ is searching for a piece of text at the end of the string, buit again, not sure what the "{2,4}" bits for ?!?!?!?!?
Can anyone help explain the "([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/" bit please ?