84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
js 正则问题 求取得各项选择["答案 一","答案二"]最好只通过A-F来取得各项
var str = "奥巴马是个好总统吗?A:是 B 不是 C、你 猜 D:这儿有可能有空格换行...等等"; var reg = /\s+[A-F][\s|:|:|、|.]+(\S+)/g;//这种写法不能取得内容有空格等的项 //return 返回['是','不是','你 猜','这儿有可能有空格换行...等等']数组
小伙看你根骨奇佳,潜力无限,来学PHP伐。
var str = "奥巴马是个好总统吗?A:是 B:不是 C:你猜"; var reg = /[A-Z]:(\S+)/gi; str.replace(reg, function (m, m1) { console.log(m1); }); var answers = str.match(reg).map(function (el) { return el.split(':')[1]; });
var src = "奥巴马是个好总统吗?A:是 B:不是 C:你猜 奥巴马是个好总统吗?A:是 B:不是 C:你猜 奥巴马是个好总统吗?A:是 B:不是 C:你猜 "; var reg1 = /[A-Z]\s*.\s*(\S+)/gi; var reg2 = /^[A-Z]\s*.\s*/; var questions = src.trim().split(/\s*\n\s*/); var answers = questions.map(function (q) { return q.match(reg1).map(function (answer) { return answer.replace(reg2, ''); }); });
questions = [ "奥巴马是个好总统吗?A:是 B:不是 C:你猜", "奥巴马是个好总统吗?A:是 B:不是 C:你猜", "奥巴马是个好总统吗?A:是 B:不是 C:你猜" ]; answer = [ ["是","不是","你猜"], ["是","不是","你猜"], ["是","不是","你猜"] ];
小伙看你根骨奇佳,潜力无限,来学PHP伐。