Home > AI > Uncategorized

正则表达式- + / .+ / .+?

+

var a = "abcABC".match(/[a-zA-Z]/);
var b = "abcABC".match(/[a-zA-Z]+/);
alert(a); //
alert(b); //abcABC

.+  / .+?

var r2 = "<span></span>".match(/<.+?>/)
var r3 = "<span></span>".match(/<.+>/)
alert(r2); //<span>
alert(r3); //<span></span>

 

Related posts:

Leave a Reply