Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please Explain line below for me ...

Status
Not open for further replies.

andreateh

Programmer
Jul 19, 2003
83
SG
I'm new to JavaScript. So can any one please explain line below for me? Thanks.

Code:
var re = /^[a-zA-Z0-9]{1}[a-zA-Z0-9\-\._]+\@{1}[a-zA-Z0-9\-\._]+\.{1}[a-zA-Z0-9\-\._]+[a-zA-Z0-9]{1}$/

Code:
^[a-zA-Z0-9]{1}
Mean First character must be between "a-z" or "A-Z" or "0-9" and exactly occur 1 time.

Code:
[a-zA-Z0-9\-\._]+\@{1}
[code]
This line should be almost as above except "a-z" or "A-Z" or "0-9" at lease 1 or more occurrence and exactly "@" occur 1 time. 

But i can't understand [b]\-\._[b] mean what ?
 
I think they are as follows:

\- is an escaped "-" character (I don't think this needs to be escaped)
\. is an escaped "." character (since "." on it's own would translate to "any single character")
_ is just a normal "_" character

Hope that helps,
Jeff
 
BillyRayPreachersSon,

the actual object is
Code:
RegExp()
, but it's easier to say "regex"

=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top