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

¸ßЧJavaScript ×Ö·û´®Ìæ»»º¯ÊýµÄbenchmark

°æȨÉùÃ÷
£º¿ÉÒÔÈÎÒâתÔØ£¬µ«×ªÔØʱ±ØÐë±êÃ÷Ô­×÷Õßcharlee¡¢Ô­Ê¼Á´½Óhttp://tech.idv2.com/2006/11/23/javascript-strreplace-benchmark/
ÒÔ¼°±¾ÉùÃ÷¡£
¸ÐлClearΪÎÒÃÇÌṩÁËÕâ¸öЧÂʸü¸ßµÄ×Ö·û´®Ìæ»»º¯Êý
¡£ÕâÊǾ­³£Ê¹ÓõÄHTMLÌØÊâ×Ö·ûÌæ»»º¯Êý£¬¼´½« &¡¢<¡¢>¡¢" µÈº¯ÊýÌæ»»³É &¡¢<¡¢>¡¢"¡£Í¨³£µÄ×÷·¨¶¼ÊÇÁ¬ÐøʹÓÃÊý¸ö replace º¯Êý£¬¶øClear½öʹÓÃÒ»¸ö replace ¾ÍÍê³ÉÁËÌæ»»¡£
ÎÒ¶ÔÕâÁ½¸öº¯Êý×÷ÁËbenchmark£¬·¢ÏÖк¯ÊýµÄЧÂÊԼΪԭº¯ÊýµÄ1.4±¶¡£ËäȻûÓÐÔ¤ÏëÖÐÄÇô¸ßЧÂÊ£¬µ«µ±ÒªÌæ»»µÄ×Ö·û´®¸ü¶àʱ£¬Ð§ÂÊÓ¦¸Ã»áÌá¸ß°É¡£
²âÊÔ·½·¨Îª£¬¶ÔÒ»¸ö2048×Ö½Ú³¤µÄ×Ö·û´®·Ö±ðÖ´ÐÐÁ½¸öº¯Êý100´Î£¬È¡ÆäÖ´ÐÐʱ¼ä¡£ÏÂÃæΪ10´Î²âÊԵĽá¹û¡£toTXT_1 Ϊͨ³£µÄ×÷·¨£¬toTXT_2 ΪClearµÄ·½·¨¡£
toTXT_1(ms)
toTXT_2(ms)
toTXT_1/toTXT_2
1609
1204
75%
2250
1547
69%
1672
1313
79%
1813
1250
69%
1844
1219
66%
2063
1421
69%
2031
1172
58%
1797
1360
76%
2015
1281
64%
1860
1500
81%
²âÊÔ´úÂ룺
<html>
<head>
<mce:script type="text/javascript"><!--
function toTXT_1(str){
str = str.replace(/\&/g, "& amp;");
str = str.replace(/\>/g, "& gt;");
str = str.replace(/\</g, "& lt;");
str = str.replace(/\"/g, "& quot;");
str = str.replace(/\'/g, "& #39;");
return str;
}
function toTXT_2(str){
var RexStr = /\<|\>|\"|\'|\&/g
str = str.replace(RexStr,
function(MatchStr){
switch(MatchStr){
case "<":
return "& lt;";
break;
case ">":
return "& gt;";
break;
case "\"":
return "& quot;";
break;
case "'":
return "& #39;";
break;
case "&":


Ïà¹ØÎĵµ£º

Javascript ÄäÃûº¯Êý¼°Æä´úÂëģʽԭÀí

֮ǰ¿´ÁËÓйØÄäÃûº¯ÊýµÄµ÷Ó㬸оõÓбØÒªºÍ´ó¼Ò·ÖÏíһϡ£
¹ØÓÚʲôÊÇÄäÃûº¯Êý£¬¼°Ëü´øÀ´µÄÓÅÊÆÔÚ±¾ÎľͲ»ÉÁË£¬ÏÈÅ׳öÒ»¸ö³£ÓõÄÄäÃûº¯Êý£º
(function(){alert('yo')})()
ºÜ¶àͬѧ֪µÀÔõôÓÃÕâÖÖÄäÃûº¯Êý£¬È´»òÐí²¢²»Ã÷°×ΪʲôÕâÑùд¾ÍÄܹ»µ÷ÓÃÄäÃûº¯Êý¡£Ò²ÐíÖªµÀºóÃæµÄÔ²À¨ºÅÊÇÖ´ÐÐÇ°ÃæµÄº¯Êý£¬¶ø²¢²»Çå³þÇ°ÃæµÄÔ² ......

ÓÃJavascriptÁ¬½ÓAccessÊý¾Ý¿âµÄ·½·¨

±¾ÎĽéÉÜjavascriptÁ¬½ÓaccessÊý¾Ý¿âµÄ·½·¨¡£Õâ¶Î´úÂëÔÚ±¾µØ¿ÉÒÔÕý³£ÔËÐУ¬ÔÚÏßÔòÐèÒª×ã¹»µÄȨÏÞ¡£ÓÉÓÚ²ÉÓÃAccessÊý¾Ý¿â£¬ËùÒÔ²¢²»Ê¹Óñê×¼µÄSQLÓ﷨ʹÓÃʱ¡£ÐèҪעÒâ¡£
Õ⼸Ìì·ÑÁËͦ´óÁ¦ÆøÔÚÍøÉϲéÕÒjavascriptÁ¬½ÓaccessÊý¾Ý¿âµÄ·½·¨£¬¾­¹ýÕûÀí×ܽᣬÖÕÓÚд³öÒ»¶ÎÄܹ»ÓÐЧִÐеĴúÂë¡£
µ«ÊÇÕâ¶Î´úÂëÔÚ±¾µØ¿ÉÒÔÕý³£ÔËÐУ ......

³£ÓõÄJavaScriptÑéÖ¤ÕýÔò±í´ïʽ

±¾ÎĽ«½éÉܼ¸¸ö³£ÓõÄJavaScriptÑéÖ¤ÕýÔò±í´ïʽ£¬ÕâЩ×ÊÁÏÏ£Íû¶Ô´ó¼ÒÔÚʵ¼Ê±à³Ì¹ý³ÌÖÐÆðµ½°ïÖú×÷Óá£
Æ¥ÅäÖÐÎÄ×Ö·ûµÄÕýÔò±í´ïʽ£º [u4e00-u9fa5]
ÆÀ×¢£ºÆ¥ÅäÖÐÎÄ»¹ÕæÊǸöÍ·ÌÛµÄÊ£¬ÓÐÁËÕâ¸ö±í´ïʽ¾ÍºÃ°ìÁË
Æ¥ÅäË«×Ö½Ú×Ö·û(°üÀ¨ºº×ÖÔÚÄÚ)£º[^x00-xff]
ÆÀ×¢£º¿ÉÒÔÓÃÀ´¼ÆËã×Ö·û´®µÄ³¤¶È£¨Ò»¸öË«×Ö½Ú×Ö·û³¤¶È¼Æ2£¬ASCII×Ö·û ......

JavaScript replace() ·½·¨

JavaScript replace() ·½·¨
JavaScript String ¶ÔÏó²Î¿¼ÊÖ²á
¶¨ÒåºÍÓ÷¨
replace() ·½·¨ÓÃÓÚÔÚ×Ö·û´®ÖÐÓÃһЩ×Ö·ûÌæ»»ÁíһЩ×Ö·û£¬»òÌæ»»Ò»¸öÓëÕýÔò±í´ïʽƥÅäµÄ×Ó´®¡£
Óï·¨
stringObject.replace(regexp,replacement)
²ÎÊýÃèÊö
regexp
±ØÐè¡£¹æ¶¨ÁËÒªÌæ»»µÄģʽµÄ RegExp ¶ÔÏó¡£Çë×¢Ò⣬Èç¹û¸ÃÖµÊÇÒ»¸ö×Ö·û´®£¬Ôò½ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ