1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| var str = "Hello Java Hello java";
var r=str.match(/java/gi);
str = "hello 2016"; r=str.match(/\w.\d/g);
str = "198" r=str.match(/1[3589]\d/);
str = "18312345678"; r=str.match(/1[3589]\d{9}/);
str = "15312345678"; r=str.match(/^1[3589]\d{9}$/); str = "153^.$[]"; r=str.match(/\^\.\$\[\]$/);
str = "12&3.jpeg"; r=str.match(/\.(?:png|gif|jpe?g)$/);
str = "-12.34E5"; r = str.match(/^(-?)(0|[1-9]\d*)(\.\d+)?([eE][-+]?\d+)?$/);
str = '欕eom旕eos瓰fenwa覅fiao猤fui甴gad嚿geo啹geu喼gib嗰go兝gongfen兣'; r=str.match(/[\u4E00-\u9FA5]/g);
str = "aabab"; r=str.match(/a.*?b/g); console.info(r);
|