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

javascript RegExp¶ÔÏó

JavaScriptÌṩÁËÒ»¸öRegExp¶ÔÏóÀ´Íê³ÉÓйØÕýÔò±í´ïʽµÄ²Ù×÷ºÍ¹¦ÄÜ£¬Ã¿Ò»ÌõÕýÔò±í´ïʽģʽ¶ÔÓ¦Ò»¸öRegExpʵÀý¡£ÓÐÁ½ÖÖ·½Ê½¿ÉÒÔ´´½¨RegExp¶ÔÏóµÄʵÀý¡£
ʹÓÃRegExpµÄÏÔʽ¹¹Ô캯Êý£¬Ó﷨Ϊ£ºnew RegExp("pattern"[,"flags"])¡£
ʹÓÃRegExpµÄÒþʽ¹¹Ô캯Êý£¬²ÉÓô¿Îı¾¸ñʽ£º/pattern/[flags]¡£
pattern²¿·ÖΪҪʹÓõÄÕýÔò±í´ïʽģʽÎı¾£¬ÊDZØÐëµÄ¡£ÔÚµÚÒ»ÖÖ·½Ê½ÖУ¬pattern²¿·ÖÒÔJavaScript×Ö·û´®µÄÐÎʽ´æÔÚ£¬ÐèҪʹÓÃË«ÒýºÅ»òµ¥ÒýºÅÀ¨ÆðÀ´£»ÔÚµÚ¶þÖÖ·½Ê½ÖУ¬pattern²¿·ÖǶÌ×ÔÚÁ½¸ö¡°/¡±Ö®¼ä£¬²»ÄÜʹÓÃÒýºÅ¡£
flags²¿·ÖÉèÖÃÕýÔò±í´ïʽµÄ±êÖ¾ÐÅÏ¢£¬ÊÇ¿ÉÑ¡Ïî¡£Èç¹ûÉèÖÃflags²¿·Ö£¬ÔÚµÚÒ»ÖÖ·½Ê½ÖУ¬ÒÔ×Ö·û´®µÄÐÎʽ´æÔÚ£»ÔÚµÚ¶þÖÖ·½Ê½ÖУ¬ÒÔÎı¾µÄÐÎʽ½ô½ÓÔÚ×îºóÒ»¸ö¡°/¡±×Ö·ûÖ®ºó¡£flags¿ÉÒÔÊÇÒÔϱêÖ¾×Ö·ûµÄ×éºÏ¡£
gÊÇÈ«¾Ö±êÖ¾¡£Èç¹ûÉèÖÃÁËÕâ¸ö±êÖ¾£¬¶Ôij¸öÎı¾Ö´ÐÐËÑË÷ºÍÌæ»»²Ù×÷ʱ£¬½«¶ÔÎı¾ÖÐËùÓÐÆ¥ÅäµÄ²¿·ÖÆð×÷Óá£Èç¹û²»ÉèÖÃÕâ¸ö±êÖ¾£¬Ôò½öËÑË÷ºÍÌæ»»×îÔçÆ¥ÅäµÄÄÚÈÝ¡£
iÊǺöÂÔ´óСд±êÖ¾¡£Èç¹ûÉèÖÃÁËÕâ¸ö±êÖ¾£¬½øÐÐÆ¥Åä±È½Ïʱ£¬½«ºöÂÔ´óСд¡£
mÊǶàÐбêÖ¾¡£Èç¹û²»ÉèÖÃÕâ¸ö±êÖ¾£¬ÄÇôԪ×Ö·û¡°^¡±Ö»ÓëÕû¸ö±»ËÑË÷×Ö·û´®µÄ¿ªÊ¼Î»ÖÃÏàÆ¥Å䣬¶øÔª×Ö·û¡°$¡±Ö»Óë±»ËÑË÷×Ö·û´®µÄ½áÊøλÖÃÏàÆ¥Åä¡£Èç¹ûÉèÖÃÁËÕâ¸ö±êÖ¾£¬¡°^¡±»¹¿ÉÒÔÓë±»ËÑË÷×Ö·û´®Öеġ°\n¡±»ò¡°\r¡±Ö®ºóµÄλÖ㨼´ÏÂÒ»ÐеÄÐÐÊ×£©ÏàÆ¥Å䣬¶ø¡°$¡±»¹¿ÉÒÔÓë±»ËÑË÷×Ö·û´®Öеġ°\n¡±»ò¡°\r¡±Ö®ºóµÄλÖ㨼´ÏÂÒ»ÐеÄÐÐ⣩ÏàÆ¥Åä¡£

var myString="ÕâÊǵÚÒ»¸öÕýÔò±í´ïʽµÄÀý×Ó";
var myregex = new RegExp("Ò»¸ö"); // ´´½¨ÕýÔò±í´ïʽ
if (myregex.test(myString)){
alert("ÕÒµ½ÁËÖ¸¶¨µÄģʽ£¡");
}
else{
alert("δÕÒµ½Ö¸¶¨µÄģʽ¡£");
}

ÔËÐдúÂë
ÓÉÓÚJavaScript×Ö·û´®Öеġ°\¡±ÊÇÒ»¸öתÒå×Ö·û£¬Òò´Ë£¬Ê¹ÓÃÏÔʽ¹¹Ô캯Êý´´½¨RegExpʵÀý¶ÔÏóʱ£¬Ó¦½«Ô­Ê¼ÕýÔò±í´ïʽÖеġ°\¡±Óá°\\¡±Ìæ»»¡£ÀýÈ磬ÔÚ´úÂë1.2ÖеÄÁ½ÌõÓï¾äÊǵȼ۵ġ£

var re1 = new RegExp("\\d{5}");
var re2 = /\d{5}/;
alert("re1="+re1+"\nre2="+re2);

ÔËÐдúÂë
ÓÉÓÚÕýÔò±í´ïʽģʽÎı¾ÖеÄתÒå×Ö·ûÒ²ÊÇ¡°\¡±£¬Èç¹ûÕýÔò±í´ïʽÖÐҪƥÅäÔ­Òå×Ö·û¡°\¡±£¬ÔÚÕýÔò±í´ïʽģʽÎı¾ÖÐÒªÒÔ¡°\\¡±À´±íʾ£¬µ±Ê¹ÓÃÏÔʽ¹¹Ô캯ÊýµÄ·½Ê½´´½¨RegExpʵÀý¶ÔÏóµÄʱºò£¬¾ÍÐèҪʹÓá°\\\\¡±À´±íʾԭÒå×Ö·û¡°\¡±¡£
var re = new RegExp(\


Ïà¹ØÎĵµ£º

javascript event ʼþ½âÎö

 ÃèÊö event´ú±íʼþµÄ״̬£¬ÀýÈç´¥·¢event¶ÔÏóµÄÔªËØ¡¢Êó±êµÄλÖü°×´Ì¬¡¢°´ÏµļüµÈµÈ¡£ event¶ÔÏóÖ»ÔÚʼþ·¢ÉúµÄ¹ý³ÌÖвÅÓÐЧ¡£  eventµÄijЩÊôÐÔÖ»¶ÔÌض¨µÄʼþÓÐÒâÒå¡£±ÈÈ磬fromElement ºÍ toElement ÊôÐÔÖ»¶Ô onmouseover ºÍ  onmouseout ʼþÓÐÒâÒå¡£ Àý×Ó ÏÂÃæµÄÀý×Ó¼ì²éÊó±êÊÇ·ñÔÚÁ´½ÓÉ ......

JavascriptÖÐ×î³£ÓõÄ55¸ö¾­µä¼¼ÇÉ

 1. oncontextmenu="window.event.returnValue=false" ½«³¹µ×ÆÁ±ÎÊó±êÓÒ¼ü
<table border oncontextmenu=return(false)><td>no</table> ¿ÉÓÃÓÚTable
2. <body onselectstart="return false"> È¡ÏûÑ¡È¡¡¢·ÀÖ¹¸´ÖÆ
3. onpaste="return false" ²»×¼Õ³Ìù
4. oncopy="return false;" oncut="re ......

javascriptÊ®½øÖÆת¶þ½øÖÆ£¬¶þ½øÖÆתʮ½øÖÆ


alert(parseInt("101101", 2))

ÔËÐдúÂë

function toBin(intNum) {
var answer = "";
if(/\d+/.test(intNum)) {
while(intNum != 0) {
answer = Math.abs(intNum%2)+answer;
intNum = parseInt(intNum/2);
}
......

JavaScript TextBoxÊäÈëÊý×Ö¿ØÖÆ

var OnPasteCheckIntNum = function()
{
    if(window.clipboardData)
    {
        if(isNaN(window.clipboardData.getData('text')))
        {
          ......

JavaScriptÖк¯ÊýµÄ´«µÝ

ÿ´ÎÓÃGoogleµÄ
 GEvent.addListener(marker, "click", function() {
                    marker.openInfoWindowHtml(num);
             &n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ