var str0 = '2013-6-7()'; var AAAAADD = str0.match(/(d)/g); //11个空字符串 //["2", "0", "1", "3", "6", "7"] var AAAAAD = str0.match(/d/g); //11个空字符串 // ["2", "0", "1", "3", "6", "7"] var AAAAAD1 = str0.match(/d+/g); //["2013", "6", "7"] var AAAAAD2 = str0.match(/(d+)/g); //["2013", "6", "7"] var AAAAAD3 = str0.match(/d+-/g); //["2013-", "6-"] var AAAAAD4 = str0.match(/d+(-)/g); //["2013-", "6-"] var AAAAAD5 = str0.match(/(d+)(-)/g); //["2013-", "6-"]
/// (d+)(-)/g = /d+(-)/g = /d+-/g || /d+/g = /(d+)/g || /d/g = /(d)/g
var data = 'windows 98 is ok'; console.log(data); console.log(data.match(/windows (?=d+)/)); // ["windows "] //(?=)会作为匹配校验,但不会出现在匹配结果字符串里面 console.log(data.match(/windows (?:d+)/)); // ["windows 98"] //(?:)会作为匹配校验,并出现在匹配结果字符里面 console.log(data.match(/windows (d+)/)); // ["windows 98", "98"] //先匹配windows 98,在匹配98 var str = "dskf(AAA)_8hjk(CCC)dsk(BBB)"; var reg = /(?:()w+(?:))/; var reg = /(?:()(?:))/; console.log(str.match(/(?:()/));//( console.log(str.match(/w+/)); //dskf console.log(str.match(/(?:))/));//) console.log("10000"); console.log(str.match(/(?:()(?:))/)); //匹配(), console.log(str.match(/(?:()w+(?:))/)); //["(AAA)"] console.log(str.match(/(?:()(w+)(?:))/)); //["(AAA)".AAA]
data = "blang001"; console.log(data); console.log(data.match(/blang/i)); //["blang"] console.log(data.match(/D/ig)); //["b"] 吧不是数字的提取出来 ["b", "l", "a", "n", "g"] console.log(data.match(/lang/i)); // lang 代表非blang 字符串, console.log(data.match(/lang(?:0)/)); var lang = /lang(?:uage)?-([w-]+)/i;
var sss = "line-numbers language-javascript"; var ss1 = "language-css"; var ss2 = "'+lan_class+'"; var lang = /lang(?:uage)?-([w-]+)/i; //var re = /one/; // e后面必须是独立的 可以是起始,空格,或结束 w : 字符 ( 字母 ,数字,下划线_ ) console.log(sss); //?-等同于-,判断后面是否是-, ?(-)等同于(-) console.log(sss.match(lang)); //["language-javascript", "javascript"] console.log(ss1.match(lang)); //["language-css", "css"] console.log(ss2.match(lang));