$字符串的结尾:
document.write("bitan".search(/n$/) + "," + "bitan".search(/it/));
4,1 |
|选择:
var a = "2005-9-13 12:05:36".split(/(-|\s|:)+/);
[0=2005];[1=9];[2=13];[3=12];[4=05];[5=36]; |
String.match()与子表达式引用:
var a = "2005-9-13 12:05:36".match(/(\d+)-(\d+)-(\d+)\s+(\d+):(\d+):(\d+)/g ); document.write("-------------------------<br>");
[input=2005-9-13 12:05:36]; [0=2005-9-13 12:05:36]; [index=0]; [lastIndex=18]; ------------------------- [input=2005-9-13 12:05:36]; [index=0]; [lastIndex=18]; [0=2005-9-13 12:05:36]; [1=2005]; [2=9]; [3=13]; [4=12]; [5=05]; [6=36]; ------------------------- [input=23.0234182345305]; [index=0]; [lastIndex=7]; [0=23.0234]; [1=23]; [2=0234]; |
String.replace()与子表达式引用:
var a = "2005-04-15 12:05:32".replace(/\d+(-|\s|:) \d+\1 \d+(-|\s|:) \d+(-|\s|:) \d+\3 \d+/, "####$1 ##$1 ##$2 ##$3 ##$3 ##");
####-##-## ##:##:## |
\b词语边界:
document.write("Java is not JavaScript".replace(/\b Java\b /gi,"VB") + "<br>");
<!--StartFragment -->VB is not JavaScript |
RegExp.multiline属性:
var s = "I come.\n I see.\n I conquer.\n ";
<!--StartFragment -->-1 |
RegExp的类属性列表:
for (i in RegExp)
<!--StartFragment -->input= |