题解 | #排序#正则表达式寻找三个连续的数字
获取指定字符串
http://www.nowcoder.com/practice/4ec56ad04a9a4402a01e50a390a8060a
function captureThreeNumbers(str) {
let test1=/(0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9))\d{2}/;
let test2=/(9(?=8)|8(?=7)|7(?=6)|6(?=5)|5(?=4)|4(?=3)|3(?=2)|2(?=1)|1(?=0))\d{2}/
if(test1.exec(str)==null&&test2.exec(str)==null)
return false;
else if(test1.exec(str)!=null)
return test1.exec(str)[0];
else
return test2.exec(str)[0];
}