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

javascriptÖÐreplaceÕýÔò±í´ïʽÓï·¨

replace()×î¼òµ¥µÄËãÊÇÄÜÁ¦¾ÍÊǼòµ¥µÄ×Ö·ûÌæ»»¡£
  ʾÀý´úÂëÈçÏ£º
<script language="javascript">
var strM = "javascript is a good script language";
//ÔÚ´ËÎÒÏ뽫×ÖĸaÌæ»»³É×ÖĸA
alert(strM.replace("a","A"));
</script>
ËüÖ»Ìæ»»ÁËÊ××Öĸ¡£µ«Èç¹û¼ÓÉÏÕýÔò±í´ïʽ½á¹û¾Í²»Ò»ÑùÁË£¡replace()Ö§³ÖÕýÔò±í´ïʽ£¬Ëü¿ÉÒÔ°´ÕÕÕýÔò±í´ïʽµÄ¹æÔòÆ¥Åä×Ö·û»ò×Ö·û´®£¬È»ºó¸øÓèÌæ»»£¡
×¢Ò⣺±»Ìæ»»µÄ²¿·Ö²»ÓüÓË«ÒýºÅ.
<script language="javascript">
var strM = "javascript is a good script language";
//ÔÚ´ËÎÒÏ뽫×ÖĸaÌæ»»³É×ÖĸA
alert(strM.replace(/a/,"A"));
</script>
ÕâÑù»¹ÊÇÖ»Ìæ»»Á˵ÚÒ»¸ö×Öĸa¡£
<script language="javascript">
var strM = "javascript is a good script language";
//Ôڴ˽«×ÖĸaÈ«²¿Ìæ»»³É×ÖĸA
alert(strM.replace(/a/g,"A"));
</script>
ÓÉÉÏ¿ÉÖª£¬µ±ÕýÔò±í´ïʽÓÐ"g"±ê־ʱ£¬´ú±í½«´¦ÀíÕû¸ö×Ö·û´®.
<script language="javascript">
var strM = "javascript is a good script language";
alert(strM.replace(/(javascript)\s*(is)/g,"$1 $2 fun. it $2"));
</script>
ÏÈ¿´¿´¼òµ¥Àý×Ó£º½«ËùÓе¥´ÊÊ××Öĸ»»³É´óд¡£
<script language="javascript">
var strM = "javascript is a good script language";
function change(word)
{
return word.indexOf(0).toUpperCase()+word.substring(1);
}
alert(strM.replace(/\b\w+\b/g,change));
</script>
ÓÉÉÏ¿ÉÖª£¬µ±ÕýÔò±í´ïʽÓÐ"g"±ê־ʱ£¬´ú±í½«´¦ÀíÕû¸ö×Ö·û´®£¬¼´º¯ÊýchangeµÄ±ä»»½«Ó¦ÓÃÓÚËùÓÐÆ¥ÅäµÄ¶ÔÏ󡣶ø¸Ãº¯ÊýÓÐÈý¸ö»ò¸ü¶à²ÎÊý£¬¾ßÌå¸öÊýÊÓÕýÔò±í´ïʽ¶ø¶¨¡£
ÓÐÁ˺¯ÊýÓëÕýÔò±í´ïʽµÄÅäºÏ£¬replace()´¦Àí×Ö·û´®µÄ¹¦ÄÜ¿ÕÇ°Ç¿´óÆðÀ´ÁË£¡
×îºó»¹¾Ù¸öÀý×Ó£¬½«×Ö·û´®ËùÓе¥´Êµ¹Ðò£¬ÓÃreplace()´¦ÀíÊÇÈç´Ë¼òµ¥¡£
<script language="javascript">
var strM = "javascript is a good script language";
function change(word)
{
var result = word.match(/(\w)/g);
if ( result )
{
var str = "";
for ( var i=result.length-1; i>=0; i


Ïà¹ØÎĵµ£º

JavaScriptÕýÔò±í´ïʽµÄÓ÷¨

JavaScriptÕýÔò±í´ïʽµÄÓ÷¨
ÕýÔò±í´ïʽÊÇÒ»ÖÖ¿ÉÒÔÓÃÓÚģʽƥÅäºÍÌæ»»µÄÇ¿´ó¹¤¾ß£¬ÔںܶàÓïÑÔÖж¼¿ÉÒÔÓ¦Óá£JavaScript¶ÔÕýÔò±í´ïʽÌṩÁ˺ܺõÄÖ§³Ö£¬
JavascriptÖÐÓÐÒ»¸öÕýÔò±í´ïʽ¶ÔÏóRegExp¡£¸Ã¶ÔÏóÌṩÁË´óÁ¿µÄÊôÐԺͷ½·¨À´´¦ÀíÕýÔò±í´ïʽ£¬Í¬Ê±£¬String¶ÔÏóÒ²ÌṩÁËÏà¹ØµÄ·½·¨À´
´¦ÀíÕýÔò±í´ïʽ£¬ÔÚWebÓ¦ÓÃÖУ¬¾­³ ......

javascript È¥µôÊý×éÖÐÇ°»òºóÖظ´Ïî

ÏÂÃæÁ½¸ö·½·¨ÊµÏÖÁËÊý×éÖÐÈ¥µô Ç°Ãæ »òÕß ºóÃæµÄ Öظ´Ïî
È¥µôÇ°ÃæµÄÖظ´Ïî·½·¨ °Ñarray [1, 2, 3, 1, 4, 5]È¥µôÇ°ÃæÖظ´Ïî µÃµ½ [2, 3, 1, 4, 5].
function unique(a)
{
var r = new Array();
o:for(var i = 0, n = a.length; i < n; i++) {
for(var x = i + 1 ; x < n; x++)
{
......

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

Javascript ÕýÔò±í´ïʽʹÓÃÊÖ²á
Javascript   2008-10-30 10:15   ÔĶÁ97   ÆÀÂÛ0  
×ֺţº ´ó´ó  ÖÐÖР СС
Ò»£®ÕýÔò±í´ïʽƥÅä³£ÓÃÓï·¨
“+”×Ö·û£º¹æ¶¨±í´ïʽ×Ö·û³öÏÖÒ»´Î»ò¶à´Î¡£
“*”×Ö·û£º¹æ¶¨±í´ïʽ×Ö·û³öÏÖÁã´Î»ò¶à´Î¡£
“? ......

javascriptÐÞ¸ÄIMG±êÇ©µÄSRCʵÏÖÑéÖ¤Âë»ðºü²»Õý³£

javascriptÐÞ¸ÄIMG±êÇ©µÄSRCʵÏÖÑéÖ¤Âëʱ,IEÕý³££¬»ðºüºÍgoogle³ö×´¿ö
1.µ±µã»÷ijһ°´Å¥µÄʱºò£¬°ÑͼƬÓòÖеÄͼƬ¸Ä±äÒ»ÏÂ
    <img id="randimg" src="/servlet/CreateValidateNum" width="60" height="20" />
    <span style="cursor:hand" onclick="reflush();return false; ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ