jquery⼀javascript 正则字符串,返回数组,如何写

2024-12-23 14:51:39
推荐回答(2个)
回答1:

var str = 'abc c bof abc d bof klasdf abc e;sdf bof';
str.match(/(abc(.*?)bof)/g);

//["abc c bof", "abc d bof", "abc e;sdf bof"]

回答2:

var reg = /abc\(\.\*\)bof/g;
var $data = "";
var array = $data.match(reg);