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

javascript replace ·½·¨ÓëjavaÖеÄreplace·½·¨


²»Óò»ÖªµÀ,Ò»ÓòÅÖªµÀÕâÁ½ÕßÊDz»´óÒ»ÑùµÄ,ÏñÔÚjavaÖÐ,ÊÇÖ±½ÓʹÓà ,Èç str1.replace("$","*") °Ñ$ºÅ±ä³É*ºÅ
µ«ÔÚjavascript¾Í²»Ò»Ñù,ҪʵÏÖÉÏÃæµÄ¹¦ÄÜÊÇÕâÑùд: str.replace(/&/g,"*") ÆäÖеÄgÊDzÎÊý,˵Ã÷Òª½«È«²¿µÄ$¶¼±ä³É*
ÏÂÃæ°ÑjavascriptµÄÕ³ÌùÔÚÏÂÃæ:
¶¨ÒåºÍÓ÷¨
replace() ·½·¨ÓÃÓÚÔÚ×Ö·û´®ÖÐÓÃһЩ×Ö·ûÌæ»»ÁíһЩ×Ö·û£¬»òÌæ»»Ò»¸öÓëÕýÔò±í´ïʽƥÅäµÄ×Ó´®¡£
Óï·¨
stringObject.replace(regexp,replacement)
²ÎÊýÃèÊö
regexp
±ØÐè¡£¹æ¶¨ÁËÒªÌæ»»µÄģʽµÄ RegExp ¶ÔÏó¡£Çë×¢Ò⣬Èç¹û¸ÃÖµÊÇÒ»¸ö×Ö·û´®£¬Ôò½«Ëü×÷ΪҪ¼ìË÷µÄÖ±½ÓÁ¿Îı¾Ä£Ê½£¬¶ø²»ÊÇÊ×Ïȱ»×ª»»Îª RegExp ¶ÔÏó¡£
replacement
±ØÐè¡£Ò»¸ö×Ö·û´®Öµ¡£¹æ¶¨ÁËÌæ»»Îı¾»òÉú³ÉÌæ»»Îı¾µÄº¯Êý¡£
·µ»ØÖµ
Ò»¸öеÄ×Ö·û´®£¬ÊÇÓà replacement Ìæ»»ÁË regexp µÄµÚÒ»´ÎÆ¥Åä»òËùÓÐÆ¥ÅäÖ®ºóµÃµ½µÄ¡£
˵Ã÷
×Ö·û´® stringObject µÄ replace() ·½·¨Ö´ÐеÄÊDzéÕÒ²¢Ìæ»»µÄ²Ù×÷¡£Ëü½«ÔÚ stringObject ÖвéÕÒÓë regexp ÏàÆ¥ÅäµÄ×Ó×Ö·û´®£¬È»ºóÓà replacement À´Ìæ»»ÕâЩ×Ó´®¡£Èç¹û regexp ¾ßÓÐÈ«¾Ö±êÖ¾ g£¬ÄÇô replace() ·½·¨½«Ìæ»»ËùÓÐÆ¥ÅäµÄ×Ó´®¡£·ñÔò£¬ËüÖ»Ìæ»»µÚÒ»¸öÆ¥Åä×Ó´®¡£
replacement ¿ÉÒÔÊÇ×Ö·û´®£¬Ò²¿ÉÒÔÊǺ¯Êý¡£Èç¹ûËüÊÇ×Ö·û´®£¬ÄÇôûÓÐÆ¥Å䶼½«ÓÉ×Ö·û´®Ìæ»»¡£µ«ÊÇ replacement ÖÐµÄ $ ×Ö·û¾ßÓÐÌض¨µÄº¬Òå¡£ÈçϱíËùʾ£¬Ëü˵Ã÷´ÓģʽƥÅäµÃµ½µÄ×Ö·û´®½«ÓÃÓÚÌæ»»¡£
×Ö·ûÌæ»»Îı¾
$1¡¢$2¡¢...¡¢$99
Óë regexp ÖÐµÄµÚ 1 µ½µÚ 99 ¸ö×Ó±í´ïʽÏàÆ¥ÅäµÄÎı¾¡£
$&
Óë regexp ÏàÆ¥ÅäµÄ×Ó´®¡£
$`
λÓÚÆ¥Åä×Ó´®×ó²àµÄÎı¾¡£
$'
λÓÚÆ¥Åä×Ó´®ÓÒ²àµÄÎı¾¡£
$$
Ö±½ÓÁ¿·ûºÅ¡£
×¢Ò⣺ECMAScript v3 ¹æ¶¨£¬replace() ·½·¨µÄ²ÎÊý replacement ¿ÉÒÔÊǺ¯Êý¶ø²»ÊÇ×Ö·û´®¡£ÔÚÕâÖÖÇé¿öÏ£¬Ã¿¸öÆ¥Å䶼µ÷Óøú¯Êý£¬Ëü·µ»ØµÄ×Ö·û´®½«×÷ΪÌæ»»Îı¾Ê¹Ó᣸ú¯ÊýµÄµÚÒ»¸ö²ÎÊýÊÇÆ¥ÅäģʽµÄ×Ö·û´®¡£½ÓÏÂÀ´µÄ²ÎÊýÊÇÓëģʽÖеÄ×Ó±í´ïʽƥÅäµÄ×Ö·û´®£¬¿ÉÒÔÓÐ 0 ¸ö»ò¶à¸öÕâÑùµÄ²ÎÊý¡£½ÓÏÂÀ´µÄ²ÎÊýÊÇÒ»¸öÕûÊý£¬ÉùÃ÷ÁËÆ¥ÅäÔÚ stringObject ÖгöÏÖµÄλÖá£×îºóÒ»¸ö²ÎÊýÊÇ stringObject ±¾Éí¡£
ʵÀý
Àý×Ó 1
ÔÚ±¾ÀýÖУ¬ÎÒÃǽ«Ê¹Óà "W3School" Ìæ»»×Ö·û´®ÖÐµÄ "Microsoft"£º
<script type="text/javascript">
var str="Visit Microsoft!"
document.write(str.replace(/Microsoft/, "W3School"))
</script>
Êä³ö£º
Visit W3School!
Àý×Ó 2
ÔÚ±¾ÀýÖУ¬ÎÒÃǽ«Ö´ÐÐÒ»´ÎÈ«¾ÖÌæ


Ïà¹ØÎĵµ£º

[תÔØ]Java°²×°ÅäÖã¨linux£©


°²×°java£º
´ò¿ªÖնˣ¬Ö´ÐÐÒÔÏÂÃüÁ»òʹÓÃAdept/ÐÂÁ¢µÃÈí¼þ¹ÜÀíÆ÷£¬ÔÚÆäÖзֱðËÑË÷"sun-java6-jre"ºÍ"sun-java6-jdk"²¢±ê¼Ç°²×°¡£
sudo apt-get install sun-java6-jre
Èç¹û¿Õ¼ä¸»Ô££¬½¨Òé°²×°Ò»¸öJDK¡£
sudo apt-get install sun-java6-jdk
Ìáʾ£º°²×°¹ý³ÌÖÐÐèÒªÄã»Ø´ðÊÇ·ñͬÒâʹÓÃЭÒ飨ÖÕ¶ËÖкìÀ¶É«µÄÌáʾ½çÃæ£ ......

Java»·¾³±äÁ¿µÄ³£ÓÃÅäÖÃ


ANT_HOME   D:\apache-ant-1.8.0-bin\apache-ant-1.8.0
AXIS2_HOME  D:\axis2-1.5.1
MAVEN_HOME  D:\apache-maven-2.2.1
java_home    C:\Program Files\Java\jdk1.6.0_18
 
 
path C:\ProgramFiles\Java\jdk1.6.0_18\bin;%AXIS2_HOME%/bin;%MAVEN_HOME%\bin;
%ANT_ ......

ÍøÂçÅÀ³æ£¨Spider£©JavaʵÏÖÔ­Àí

“ÍøÂçÖ©Öë”»òÕß˵“ÍøÂçÅÀ³æ”£¬ÊÇÒ»ÖÖÄÜ·ÃÎÊÍøÕ¾²¢¸ú×ÙÁ´½ÓµÄ³ÌÐò£¬Í¨¹ýËü£¬¿É¿ìËٵػ­³öÒ»¸öÍøÕ¾Ëù°üº¬µÄÍøÒ³µØͼÐÅÏ¢¡£±¾ÎÄÖ÷Òª½²ÊöÈçºÎʹÓÃJava±à³ÌÀ´¹¹½¨Ò»¸ö“Ö©Ö딣¬ÎÒÃÇ»áÏÈÒÔÒ»¸ö¿É¸´ÓõÄÖ©ÖëÀà°ü×°Ò»¸ö»ù±¾µÄ“Ö©Ö딣¬²¢ÔÚʾÀý³ÌÐòÖÐÑÝʾÈçºÎ´´½¨Ò»¸öÌض¨µÄ“Ö ......

ÎÒ¶ÔJava Serializable£¨ÐòÁл¯£©µÄ×ܽá

1¡¢ÐòÁл¯ÊǸÉʲôµÄ£¿
       ¼òµ¥Ëµ¾ÍÊÇΪÁ˱£´æÔÚÄÚ´æÖеĸ÷ÖÖ¶ÔÏóµÄ״̬£¨Ò²¾ÍÊÇʵÀý±äÁ¿£¬²»ÊÇ·½·¨£©£¬²¢ÇÒ¿ÉÒ԰ѱ£´æµÄ¶ÔÏó״̬ÔÙ¶Á³öÀ´¡£ËäÈ»Äã¿ÉÒÔÓÃÄã×Ô¼ºµÄ¸÷ÖÖ¸÷ÑùµÄ·½·¨À´±£´æobject states£¬µ«ÊÇJava¸øÄãÌṩһÖÖÓ¦¸Ã±ÈÄã×Ô¼ººÃµÄ±£´æ¶ÔÏó״̬µÄ»úÖÆ£¬ÄǾÍÊÇÐòÁл¯¡£
2¡¢Ê²Ã´Çé¿öÏ ......

javaÖг£ÓõÄÊý¾Ýת»»

javaÖг£ÓõÄÊý¾Ýת»»
ǰЩÌìÔÚÏîÄ¿ÖÐÓöµ½ÁËCalenderºÍDateµÄÏ໥ת»»ÎÊÌ⣬Ȼºó¾Í²éÁËһЩ×ÊÁÏ¡£ÕûÀíÁËһЩÏà¹ØµÄ³£ÓÃת»»£¬ºÍ´ó¼Ò·ÖÏíÏ£º
1. Java°ü×°ÀࣺÔÚ½éÉܾßÌåµÄÊý¾ÝÀàÐÍת»»Ö®Ç°£¬ÎÒÃÇÓбØÒªÏȽéÉÜjavaÖеÄÒ»¸öÌØÊâµÄ²ð×°ÏäÀàÐÍ----java°ü×°Àà¡£
• Java°ü×°Àà³öÏÖµÄÄ¿µÄ£ºÎªÁËÄܹ»Ê¹java³ÌÐòÔ±¿ÉÒÔ½«ja ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ