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

JavaScript ÓÃÓÚģʽƥÅäµÄ RegExp ·½·¨

±¾ÆªÈÕÖ¾ÏÈÖ÷ÒªÌÖÂÛ RegExp ¶ÔÏóµÄ²¿·Ö·½·¨£¬RegExp ¶ÔÏó¶¨ÒåÁËÁ½¸öÓÃÓÚģʽƥÅäµÄ·½·¨£¬ËüÃÇÊÇexec()
ºÍtest()
ÏÂÃæÎÒÃÇÖðÒ»½øÐн²½â
¡£ºÇ£¬ºÍÉÏƪÈÕÖ¾Ò»ÑùµÄ½éÉÜ£¬¿´À´Ì×»°£¬¹ûÈ»ÊÊÓÃÓÚ¶à¸ö³¡ºÏ¡£àÅ¡£
exec() ¼ìË÷×Ö·û´®ÖеÄÖ¸¶¨Öµ£¬·µ»ØÖµÊDZ»ÕÒµ½µÄÖµ£¬Èç¹ûûÓз¢ÏÖÆ¥Å䣬Ôò·µ»Ø null£º
Ö÷ÒªµÄRegExpģʽƥÅä·½·¨ÊÇexec()£¬ÆäÓëÉÏһƪ½éÉܵÄString¶ÔÏóµÄmatch·½·¨ÏàËÆ£¬Ö»²»¹ýËüÊÇÒÔ×Ö·û´®Îª²ÎÊýµÄRegExp·½·¨£¬¶ø²»ÊÇÒÔRegExp¶ÔÏóΪ²ÎÊýµÄ×Ö·û´®·½·¨¡£ºô£¬ÕâÒ»¾äÓеãÏñÈÆ¿ÚÁû°ì·¨£¬ÊéÉϵÄÔ­»°£¬³­¹ýÀ´Èôó¼ÒÀÖÒ»ÀÖ£¬ºÇ¡£exec()·½·¨ÔÚÒ»¸ö×Ö·û´®ÖмìË÷Æ¥Å䣬Èç¹ûûÓÐÕÒµ½ÈκÎÆ¥Åä·µ»Ønull£¬Èç¹ûËüÕÒµ½ÁËÒ»¸öÆ¥Å䣬½«·µ»ØÒ»¸öÊý×é¡£
¾ÍÏñ·½·¨match()Ϊ·ÇÈ«¾Ö¼ìË÷·µ»ØµÄÊý×éÒ»Ñù¡£Õâ¸öÊý×éµÄÔªËØ0°üº¬µÄÊÇÓëÕýÔò±í´ïʽÏàÆ¥ÅäµÄ×Ö·û´®£¬ÓàϵÄËùÓÐÔªËØ°üº¬µÄÊÇÓë×Ó±í´ïʽÏàÆ¥ÅäµÄ×Ó´®£¬¶øÇÒÊôÐÔindex°üº¬ÁËÆ¥Åä·¢ÉúµÄ×Ö·ûµÄλÖã¬ÊôÐÔinputÒýÓõÄÊDZ»¼ìË÷µÄ×Ö·û´®¡£
/*
i is 0  http://www.xiaoxiaozi.com/index.php
i is 1  http
i is 2  www.xiaoxiaozi.com
i is 3  index.php
i is index  11
i is input  my home is http://www.xiaoxiaozi.com/index.php
*/
var
str =
'my home is http://www.xiaoxiaozi.com/index.php'
;
var
pattern =
/(\w+):\/\/([\w.]+)\/(\S*)/
;
//var result = str.match(pattern);
var
result =
pattern.exec
(
str)
;
for
(
i in
result)
{
        document.write
(
"i is "
+
i+
"  "
+
result[
i]
+
"<br/>"
)
;
}
Óëmatch()·½·¨²»Í¬µÄÊÇ£¬exec()·µ»ØµÄÊý×éÀàÐͲ»Í¬£¬ÎÞÂÛ¸ÃÕýÔò±í´ïʽÊÇ·ñº¬ÓÐÈ«¾ÖÊôÐÔg¡£ÒòΪµ±º¬ÓÐÈ«¾ÖÊôÐÔgµÄʱ
ºò£¬match()·½·¨·µ»ØµÄÊÇÒ»¸öÆ¥ÅäµÄÊý×飬¶øµ÷ÓÃexec()·½·¨µÄRegExpÓÐÒ»¸ölastIndexÊôÐÔ£¬Ëü½«°Ñ¸Ã¶ÔÏóµÄlastIndex
ÊôÐÔÉèÖõ½½ô½Ó×ÅÆ¥Åä×Ó´®µÄ×Ö·ûλÖá£
µ±Í¬Ò»¸öRegExp¶ÔÏóµÚ¶þ´Îµ÷ÓÃexec()ʱ£¬Ëü½«´ÓlastIndexÊôÐÔËùָʾµÄ×Ö·û´¦¿ªÊ¼¼ìË÷£¬Èç¹ûexec()ûÓз¢ÏÖÈκÎÆ¥Å䣬Ëü
»á½«lastIndexÊôÐÔÖØΧΪ0£¬(ÔÚÈκÎʱºòÄ㶼¿ÉÒÔ½«lastIndexÊôÐÔÉèΪ0£¬Ã¿µ±ÄãÔÚÒ»¸ö×Ö·û´®ÖÐÕÒµ½×îºóÒ»¸öÆ¥Åä֮ǰ¾Í¿ªÊ¼ÓÃͬһ¸ö
RegExp¶ÔÏóÀ´¼ìË÷ÁíÒ»¸ö×Ö·û´®£¬¶ø·ÅÆúÁËÔ­À´µÄ¼ìË÷µÄʱºò¾Í·½·¨Ó¦¸ÃÕâÑù×ö)¡£ÕâÒ»ÌØÊâµÄÐÐΪʹ


Ïà¹ØÎĵµ£º

ÀûÓÃjavascriptÑéÖ¤ÓÊÏäµØÖ·ÊÇ·ñºÏ·¨

Ô´´úÂëÈçÏ£º
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>ÑéÖ¤ÓÊÏäµØÖ·ºÏ·¨ÐÔ</title>
    <sc ......

Javascript´úÂëʵÏÖͼƬ²£Á§ÌØЧ

ÎļþÄÚÈÝÈçÏ£º£¨Á½¸öÎļþglossy.jsºÍglossy.html£©
/**********************************  glossy.js  ***********************************/
 /**
* glossy.js 1.31 (19-Jul-2007)
* (c) by Christian Effenberger
* All Rights Reserved
* Source: glossy.netzgesta.de
* Distrib ......

JavaScript isNaN() º¯Êý


·µ»Ø JavaScript È«¾Ö¶ÔÏó²Î¿¼ÊÖ²á
¶¨ÒåºÍÓ÷¨
isNaN() º¯ÊýÓÃÓÚ¼ì²éÆä²ÎÊýÊÇ·ñÊÇ·ÇÊý×ÖÖµ¡£
Óï·¨
isNaN(x)
²ÎÊýÃèÊö
x
±ØÐè¡£Òª¼ì²âµÄÖµ¡£
·µ»ØÖµ
Èç¹û x ÊÇÌØÊâµÄ·ÇÊý×ÖÖµ NaN£¨»òÕßÄܱ»×ª»»ÎªÕâÑùµÄÖµ£©£¬·µ»ØµÄÖµ¾ÍÊÇ true¡£Èç¹û x ÊÇÆäËûÖµ,Ôò·µ»Ø false¡£
˵Ã÷
isNaN() º¯Êý¿ÉÓÃÓÚÅжÏÆä²ÎÊýÊÇ·ñÊÇ NaN£ ......

10¸ö·Ç³£°ôµÄAjax¼°JavascriptʵÀý×ÊÔ´ÍøÕ¾

1.Ajax Rain
¡¡¡¡AjaxRainÓкܶàÍêÃÀÕûºÏAJAX, CSS, DHTML »ò JavascriptµÄʵÀý£¬ÓÐһЩDemoµÄÈ·ÖµµÃÄãÈ¥¿´Ò»¿´£¬¼´Ê¹Äã²»ÊÇÍøÒ³Éè¼Æ(¿ª·¢)ʦ¡£
Ajax/JavascriptʵÀý:
 EXT JS Date Picker
 jQuery Feed Menu
 jGrowl
 FastFind Menu – Jquery
 Spiffy Accordion
2.Ajax Daddy ......

JavaScriptʵ¼ÊÓ¦Ó㺶ԲãµÄ¿ØÖÆ

²ãµÄ¿ª·¢ÔÚʵ¼ÊÓ¦ÓÃÖбȽÏÖØÒª£¬±ÈÈçƯ¸¡¹ã¸æµÈµÈ£¬ÎÒÕâÀï¼òµ¥Ì½ÌÖһϡ£
1.  ¿ØÖƲãµÄÏÔʾ»òÒþ²Ø
Á½ÖÖ°ì·¨£¬Æäʵ¶¼ÊÇ¿ØÖÆÑùʽµÄ¡£
°ì·¨Ò»£º¿ØÖÆ display ÊôÐÔ
<script language="javascript">
function show(status)
{
          document.getElemen ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ