Life is good

Sharing is better

Free is the best!

Javascript Regular Expression

I found an artical talking about the javascript regular expression. Here is the copy of this article:

var re = /^[A-Za-z]\w{6,}[A-Za-z]$/;
if (!re.test(myString)) { alert("Please enter a valid password!"); }

The ^ looks for something at the start of the string. The brackets indicate the valid character set. So it must start with an upper or lower case letter. After that, the \w means there can be valid alphanumeric characters (numbers 0-9, upper/lower case letters a-z, the underscore) and says there must be at least 6 (but no upper limit). Then comes another set and the $ looks for something at the end of the string. So this statement says there must be a letter, then at least 6 of any alphanumeric characters, then a letter (making 8 the minimum number of characters).

In this second example, the password length doesn't matter, but the password must contain at least 1 number, at least 1 lower case letter, and at least 1 upper case letter.

var re = /^\w*(?=\w*\d)(?=\w*[a-z])(?=\w*[A-Z])\w*$/
if (!re.test(myString)) { alert("Please enter a valid password!"); }

Again, the ^ and $ are looking for things at the start and end. The "\w*" combination is used at both the start and the end. \w means any alphanumeric character, and * means zero or more. You'll see why it's "zero or more" in a bit. Between are groupings in parentheses. The "(?" combination is a flag in regular expressions. Basically, they say "apply the following formula, but don't consume any of the string". In this example, instead of specifying the order that things should appear, it's saying that it must appear but we're not worried about the order.

The first grouping (called an "atom" in "regular expresion speak") uses the = sign. This means that there must be a match. Other choices are ! for a negative match (the string must not look like this). There are others (more complicated) for preceeding matches and stuff. We can refer you to a regular expression syntax web site for further details.

After the = sign comes "\w*\d". Again, any alphanumeric character can happen zero or more times, then any digit (\d means any digit from 0 to 9) can happen. So this checks to see if there is at least one number in the string. But since the string isn't comsumed, that one digit can appear anywhere in the string.

The next atom (grouping) is (?=\w*[a-z]). This is similar to the digit grouping, except it looks for a lower case letter. Again, the lower case letter can appear anywhere, but there has to be at least one.

The third atom is (?=\w*[A-Z]) which looks for an upper case letter somewhere in the string.

Finally, at the end is zero or more alphanumeric characters. To match this string, the minimum characters needed is 3 (one upper case letter, one lower case letter, and one number).

Comments
1.
mpjsnu (6/20/2010)
tWQXap mrrramflrrwm, [url=http://ozsypcvrwsus.com/]ozsypcvrwsus[/url], [link=http://cswnhhbwvxbv.com/]cswnhhbwvxbv[/link], http://ykmqctnqzrkq.com/

2.
JowiBlanco (6/21/2010)



5.
YakyuBoy (6/27/2010)

6.
tunigconcept (6/30/2010)




10.


12.

13.
RegandStav (7/8/2010)

14.
Nirvana90m (7/9/2010)

15.


17.

18.

19.
liv2mtbk (7/17/2010)
valium 27499 tramadol :-((( to buy propecia 622 xanax 401386 phentermine >:-]]]


21.
hotblknstrong (7/18/2010)

22.
LondonMerc (7/19/2010)


24.
LucYouSama (7/23/2010)

25.
small4ward (7/24/2010)

26.
moreboost (7/25/2010)


28.
ErzurumCrueL (7/27/2010)

29.

30.
bobringer (7/29/2010)


32.
d27and (8/1/2010)



35.
GerStarf (8/4/2010)


37.
xynyekzr (11/7/2011)
hu0YRo wmrleajjiubb, [url=http://aeaamirrnszq.com/]aeaamirrnszq[/url], [link=http://kgbfgcguabvc.com/]kgbfgcguabvc[/link], http://nwoivbakbaev.com/

38.
jnkfvhoh (11/30/2011)
Igv4Sj tskqovvhugun, [url=http://bkdvvmexlupo.com/]bkdvvmexlupo[/url], [link=http://wedxjvyynrcr.com/]wedxjvyynrcr[/link], http://ysvmmfddoeme.com/

39.
doimpdbt (11/30/2011)
G2IPFE lndpvujuilbm, [url=http://caguvcqrsbnf.com/]caguvcqrsbnf[/url], [link=http://ozdmekirlzwp.com/]ozdmekirlzwp[/link], http://ypphzlswlblc.com/

40.
Czahfddgsfjhgsjhg (11/30/2011)
buy ambien no prescription - buy ambien online reviews

41.
Tzabsgiusdd (12/1/2011)
buy phentermine no prescription online - buy phentermine online no prescription cheap

42.
Czahdgdsfjhgsjhg (12/2/2011)
buy valium usa - buy valium online overnight delivery

43.
Ogaydgsysuus (12/2/2011)
purchase xanax no prescription - xanax no prescription generic

44.
Czahgdfsjhgsjhg (12/3/2011)
phentermine buy online no prescription - buy phentermine in canada online

45.
Ogarysysuus (12/4/2011)
buy valium - buy valium diazepam

46.
Czahgugsfjhgsjhg (12/4/2011)
ambien online pharmacy - order generic ambien online

47.
Czahghtsfjhgsjhg (12/6/2011)
buy cheap phentermine 37.5 mg - phentermine 37.5 online pharmacy

48.
Czahgstsfjhgsjhg (12/8/2011)
buy xanax us - buy xanax online what is the cheapest

49.
Vzabtnfshsbui (12/10/2011)
valium online to buy uk - valium online usa

50.
Vzaugihsuihuihd (12/11/2011)
buy ambien 10mg online - buy ambien internet

51.
Ozbagtyfvsyusy (12/14/2011)
buy cialis online for cheap - buy generic cialis tadalafil

52.
aojntncsdjg (12/14/2011)
F7U3fC oddobxismnko, [url=http://mneljlitbijo.com/]mneljlitbijo[/url], [link=http://hquvgrbidxik.com/]hquvgrbidxik[/link], http://ksolsclnarfa.com/

53.
Dzaigjsodojidf (12/15/2011)
how to order phentermine - buy phentermine diet pills

54.
Ozbafgvsyusy (12/15/2011)
valtrex no prescription generic - generic valtrex online no prescription

55.
Ogaysyfsuuas (12/17/2011)
online pharmacy cialis canadian - online pharmacy no prescription india

56.
Gzvafyayogsyg (12/19/2011)
cheap ambien online no prescription - where to buy ambien online

57.
Uzabgsuihsiuhs (12/21/2011)
buy valtrex online rx - buy valtrex online

58.
Ogaysyjsuus (12/22/2011)

59.
Ogaydlsysuus (12/22/2011)
purchase xanax alprazolam - buy xanax us

60.
Czahgsgfjhgsjhg (12/23/2011)
buy accutane online india - accutane online canadian pharmacy

61.
Viagra Kaufen (12/24/2011)
yXWGRk wo kann kaufen viagra rezeptfrei billig viagra kaufen kauf von viagra

62.
Viagra (12/24/2011)
T4ZoP6 http://viagrakaufenapotheke.com/ auf welcher seite kann ich viagra kaufen Viagra Kaufen Online medikamente viagra kaufen

63.
cialis generico (12/24/2011)
LxkQEt http://cialisgenericofarmacia.com prostatite e cialis compra cialis viagra obmani no ostancia cialis levitra fimosi cialis

64.
cialis generico (12/25/2011)
http://cialisgenericofarmacia.com cialis 20 tariffe Cialis Generico Prezzo comprare il cialis prescrizione medica cialis su internet anche

65.
Buy Kamagra (12/25/2011)
http://kamagrabestprice.com/ kamagra india buy kamagra jelly viagra 100mg cheap kamagra cheap kamagra jelly our

66.
Buy Kamagra (12/25/2011)
http://kamagrabestprice.com/ kamagra online without prescription buy kamagra jelly generic kamagra tablets kamagra online sildenafil citrate

67.
zithromax (12/26/2011)
http://zithromaxph.com/ order azithromycin macrolide antibiotics zithromax z-pak prednisone and azithromycin drug

68.
zithromax (12/26/2011)
http://zithromaxph.com/ azithromycin pharmacy without prescription azithromycin 500mg zithromax generic price

69.
zithromax (12/26/2011)
http://zithromaxph.com/ purchase online azithromycin 250mg buy zithromax online zithromax online without a prescription z pak

70.
zithromax (12/27/2011)
http://zithromaxph.com/ zithromax order online azithromycin vomit zithromax generic

71.
zithromax (12/27/2011)
http://zithromaxph.com/ zithromax drug definition buy zithromax azithromycin 1200 mg zithromax

72.
Buy zithromax (12/27/2011)
http://zithromaxph.com/ zithromax coupon yeast infection azithromycin pharmacy zithromax and yasmin zithromax online

73.
Xenical (12/28/2011)
http://xenicalo.com/ slimming pills buy xenical Orlistat online alli orlistat coupon buy xenical cheap lose weight

74.
Azithromycin (12/28/2011)
http://zithromaxi.com/ one buy zithromax without azithromycin 500mg zithromax drug classification susceptible azithromycin drug interactions pseudomembranous colitis

75.
Isotretinoin (12/28/2011)
http://accutanepharm.com sore throat accutane drug accutane pharmacy buying accutane online order accutane online india

76.
buy Rogaine (12/28/2011)
http://rogainepharm.com/ propecia finasteride 1mg minoxidil online minoxidil and finasteride propecia cheap brand viagra generic propecia

77.
Cheap Viagra Online (12/29/2011)
http://viagraonlinerxp.com/ order viagra online ontario generic viagra i buy viagra in buy viagra computer safely

78.
Canadian Pharmacy (12/30/2011)
http://canadianpharmacyed.com/ cvs pharmacy richmond va canada drugs walgreens pharmacy prices pharmacy tech program

79.
Czahrgeujy (12/30/2011)
order zithromax online no prescription - buy generic zithromax online

80.
Czahhguj (12/31/2011)
buy propecia in uk - propecia online america

81.
Czahhguj (12/31/2011)
propecia online sales - buy propecia online

82.
Czahhguj (12/31/2011)
buy propecia in uk - order propecia pills

83.
Czahhguj (12/31/2011)

84.
Czahhguj (12/31/2011)
buy propecia online new zealand - buy propecia discount

85.
Czahrgok (1/1/2012)
ambien online pharmacy - ambien online pharmacy

86.
Buy Viagra (1/1/2012)
http://buycheapgenericviagraph.com/ can you buy viagra in the uk Viagra address order viagra viagra price walgreens canadian

87.
Czahrgeujy (1/1/2012)
order zithromax azithromycin - buy generic zithromax no prescription

88.
Czahhguj (1/1/2012)
buy propecia online cheap - buy propecia online canada

89.
Czahrgeujy (1/2/2012)
buy zithromax tabs - buy zithromax no prescription mastercard

90.
Czahhguj (1/2/2012)
buy propecia online without rx - buy propecia in australia

91.
Czahrgeujy (1/2/2012)

92.
Czahgsejy (1/3/2012)
buy propecia online with no prescription - buy propecia online no prescription needed

93.
Czahgdec (1/3/2012)
buy zithromax cheap - buy generic zithromax no prescription

94.
Czahrged (1/3/2012)
buy generic xanax cheap - buy xanax online legally

95.
Czahgujh (1/9/2012)
xanax no prescription - buy xanax from china

96.
Azithromycin (1/12/2012)
http://zithromaxazi.com/ novo azithromycin drug interactions zithromax active ingredient cheap zithromax and uti buy zithromax

97.
cheap xanax (1/30/2012)
blood system xanax online xanax price order buy xanax http://xanaxtips.com order xanax generic

98.
buy propecia (2/27/2012)
comment3, propecia cost, [url="http://propeciaonlinepharmacies.com"]propecia cost[/url], http://propeciaonlinepharmacies.com propecia cost, fki, northwest pharmacy, [url="http://canadianpharmacyfirst.com/"]northwest pharmacy[/url], http://canadianpharmacyfirst.com/ northwest pharmacy, 473, ViagraItaliaFarmacia.com, [url="http://viagraitaliafarmacia.com/"]ViagraItaliaFarmacia.com[/url], http://viagraitaliafarmacia.com/ ViagraItaliaFarmacia.com, >:[[, Generic Tadalafil, [url="http://www.cialisonlinepharmacies.com/"]Generic Tadalafil[/url], http://www.cialisonlinepharmacies.com/ Generic Tadalafil, 77490,
Add Comment
*Name (required)


*Mail (will not be published) (required)
Allowed Tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
rel="nofollow" in use - no link dropping, no keywords or domains as names;do not spam, and do not advertise!


 
Home| Articles | Gallery | Resources| About | Contact

This website is designed by Inchol Solutions and powered by Inchol Bolee3.0 CMS   Copyright © wenjunw.com All rights reserved