Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Javascript ÕýÔò±í´ïʽʹÓÃÊÖ²á

Javascript ÕýÔò±í´ïʽʹÓÃÊÖ²á
Javascript   2008-10-30 10:15   ÔĶÁ97   ÆÀÂÛ0  
×ֺţº ´ó´ó  ÖÐÖР СС
Ò»£®ÕýÔò±í´ïʽƥÅä³£ÓÃÓï·¨
“+”×Ö·û£º¹æ¶¨±í´ïʽ×Ö·û³öÏÖÒ»´Î»ò¶à´Î¡£
“*”×Ö·û£º¹æ¶¨±í´ïʽ×Ö·û³öÏÖÁã´Î»ò¶à´Î¡£
“?”×Ö·û£º¹æ¶¨±í´ïʽ×Ö·û³öÏÖÁã´Î»òÒ»´Î¡£
^ Æ¥ÅäµÄÊÇ×Ö·ûµÄ¿ªÍ· ,Æ¥ÅäµÄÊÇÒ»ÐеĿªÍ·
$ Æ¥ÅäµÄÊÇ×Ö·ûµÄ½áβ ,Æ¥ÅäµÄÊÇÒ»ÐеĽáβ
\b Æ¥ÅäµÄÊÇÒ»¸ö´ÊÓïµÄ±ß½ç.¼ò¶øÑÔÖ®¾ÍÊÇλÓÚ×Ö·û\w ºÍ \wÖ®¼äµÄλÖÃ(×¢Òâ:[\b]Æ¥ÅäµÄÊÇÍ˸ñ·û)
\B Æ¥ÅäµÄÊÇ·Ç´ÊÓïµÄ±ß½çµÄ×Ö·û
[A-Z]¡¡Æ¥Åä´ÓAµ½Z·¶Î§ÄÚÈκÎÒ»¸ö´óд×Öĸ¡£
[a-z]¡¡ Æ¥Åä´Óaµ½z·¶Î§ÄÚÈκÎÒ»¸öСд×Öĸ¡£
[0-9]/¡¡Æ¥Åä´Ó0µ½9·¶Î§ÄÚÈκÎÒ»¸öÊý×Ö¡£
([a-z][A-Z][0-9])+¡¡ Æ¥ÅäÈκÎÓÉ×ÖĸºÍÊý×Ö×é³ÉµÄ×Ö·û´®£¬Èç “aB0” µÈ¡£
\d  Æ¥ÅäÒ»¸öÊý×Ö×Ö·û¡£µÈ¼ÛÓÚ [0-9]
\D  Æ¥ÅäÒ»¸ö·ÇÊý×Ö×Ö·û¡£µÈ¼ÛÓÚ [^0-9]
\f  Æ¥ÅäÒ»¸ö»»Ò³·û¡£µÈ¼ÛÓÚ \x0c ºÍ \cL
\n  Æ¥ÅäÒ»¸ö»»Ðзû¡£µÈ¼ÛÓÚ \x0a ºÍ \cJ
\r  Æ¥ÅäÒ»¸ö»Ø³µ·û¡£µÈ¼ÛÓÚ \x0d ºÍ \cM
\s  Æ¥ÅäÈκοհ××Ö·û£¬°üÀ¨¿Õ¸ñ¡¢ÖƱí·û¡¢»»Ò³·ûµÈµÈ,µÈ¼ÛÓÚ [ \f\n\r\t\v]
\S£ºÓÃÓÚÆ¥Åä³ýµ¥¸ö¿Õ¸ñ·ûÖ®ÍâµÄËùÓÐ×Ö·û£»
\w  Æ¥Åä°üÀ¨Ï»®ÏßµÄÈκε¥´Ê×Ö·û,µÈ¼Û[A-Za-z0-9_]
\W  Æ¥ÅäÈκηǵ¥´Ê×Ö·û,µÈ¼ÛÓÚ [^A-Za-z0-9_]
 
¶þ£®×Ö·û´®µÄJavascript ÕýÔò±í´ïʽ´¦Àí
(1)´´½¨regular expressionÓÐÁ½ÖÖ·½·¨£¬Ò»ÖÖÊÇÖ±½ÓʹÓÃ×Ö·û´®¶¨Òå;ÁíÒ»ÖÖÊÇʹÓÃReqExp¹¹Ô캯Êý´´½¨¡£
Óï·¨ 1: re = /pattern/[flags]
Óï·¨ 2 ;re = new RegExp("pattern",["flags"])
Èç¹ûʹÓÃÓï·¨ 1£¬Óà "/" ×Ö·û·Ö¸ôģʽ¡£
Èç¹ûÓÃÓï·¨ 2£¬ÓÃÒýºÅ½«Ä£Ê½ÒýÆðÀ´£»Èçnew RegExp("hello","g");
Flags¿ÉÑ¡Ïî,¿ÉÒÔÓÃÒÔϲÎÊý£º
g £¨È«ÎIJéÕÒ³öÏÖµÄËùÓÐ pattern£©
i £¨ºöÂÔ´óСд£©
m £¨¶àÐвéÕÒ£©
ÀýÈ磺
·½·¨1£º var pattern = /sS/;
·½·¨2£º var pattern = new RegExp("sS");
 var zipcode=new ReqExp("\\d{5}","g");     //µÚÒ»¸ö±äÁ¿ÊÇÕýÔò±í´ïʽ(/ / ÀïµÄ)£¬µÚ¶þ¸öÊÇÓÃ//À´¼Ói»ògµÄ¡£ºöÂË´óСд²¢ËÑË÷
(2£©String¶ÔÏó³£Ó÷½·¨
search·½·¨¡£
“JavaScript”.search(/script/i/);//Õâ¸ö·½·¨·µ»ØÖµÊÇ4£¬Ò²¾ÍÊÇjavascriptµÚÎå¸ö×Öĸ¡£¿ªÊ¼ÖµÊÇ0£¬ËùÒÔÊÇ4¡£


Ïà¹ØÎĵµ£º

javascript±àдweb×é¼þ£º¶à¼¶²Ëµ¥

    ÔÚwebÉϱàд²Ëµ¥Ò»Ö±ÊDZȽÏÍ·ÌÛµÄÊÂÇ飬ҪÊÇÓиöÀàÖ±½ÓÌ×ÓþͺÃÁË£¬×î½üÓÖÒª×öÍøÕ¾ÁË£¬·³ÈË£¬ÒªÇó×öµÄ»¹ÊǶ༶²Ëµ¥£¬°¦£¬·Ï»°ÉÙ˵£¬Óöµ½ÎÊÌâ¾ÍÒª½â¾ö°¡£¬¿´´úÂ룺
   function is(e, handler) {  
    if (e.type != 'mouseout' && e.type != 'mouseover ......

[JavaScript]ÀàÖ®Èý


Ïê½âjavascriptÀà¼Ì³Ð»úÖƵÄÔ­Àí
Ä¿Ç° javascriptµÄʵÏּ̳з½Ê½²¢²»ÊÇͨ¹ý“extend”¹Ø¼ü×ÖÀ´ÊµÏֵģ¬¶øÊÇͨ¹ýconstructor functionºÍprototypeÊôÐÔÀ´ÊµÏּ̳С£Ê×ÏÈÎÒÃÇ´´½¨Ò»¸öanimalÀà
js ´úÂë
 
 var animal = function(){  //Õâ¾ÍÊÇconstructor function ÁË&nbs ......

javascript Öеļ̳з½·¨

1.¿ÉÒÔͨ¹ýprototypeÊôÐÔ£¬ÊµÏּ̳з½·¨µÄ·½Ê½£¬ÕâÖÖ·½Ê½¾ÍÊÇjavaÓïÑÔÖм̳еı任ÐÎʽ¡£
 // Create the constructor for a Person object
function Person( name ) {
    this.name = name;
}
// Add a new method to the Person object
Person.prototype.getName = function() {
   ......

JavaScript ÕýÔò±í´ïʽ Ñ¡Ôñ¡¢·Ö×éºÍÒýÓÃ

JavaScriptµÄÕýÔò±í´ïʽ֧³Ö²¼¶û²Ù×÷£¬³ýÁË×÷Ϊ Ñ¡ÔñµÄ“²¼¶û»ò”²Ù×÷Ö®Í⣬ÕýÔò±í´ïʽ»¹Ö§³Ö·Ö×éºÍÒýÓÃ
¡£ÆäʵѡÔñ¡¢·Ö×éºÍÒýÓõÄ×÷Ó÷ֱðΪ£ºÖ¸¶¨Ñ¡ÔñÏî¡¢¶Ô×Ó±í´ïʽ·Ö×éºÍÒýÓà ǰһ×Ó±í´ïʽµÄÌØÊâ×Ö·û¡£
ÕýÔò±í´ïʽµÄÑ¡Ôñ£º
ËùνѡÔñ¼´ÔÚ¶à¸öÌõ¼þÀïÃæÑ¡ÔñÒ»¸ö£¬±ÈÈç˵ÂôË®¹ûµÄ´óү˵ËÍÄã¸öË®¹û£¬Äã¿ÉÒÔÑ¡Ô ......

javascriptÊý×é½éÉÜ

1          JavaScriptÊý×é¼ò½é
JavaScriptÊý×éÊÇÒ»ÖÖ°üº¬ÒѱàÂëµÄÖµµÄ¸´ºÏÊý¾Ý¡£Êý×éÇø±ðÓÚ¹ØÁªÊý×飬¹ØÁªÊý×éÊǽ«ÖµºÍ×Ö·û´®¹ØÁªÔÚÒ»Æ𣬶øÊý×éÊǽ«ÖµºÍ·Ç¸ºÕûÊý¹ØÁªÔÚÒ»Æð¡£
Êý×éÊǶÔÏó(¿ÉÀûÓÃtypeofÔËËã·û)¡£
2          ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ