We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
var str = "013d1we22ewfa33rr4rwq0dsf00dsf9fas999"; var getNum = function (Str, isFilter) { //用来判断是否把连续的0去掉 isFilter = isFilter || false; const finallyResult = []; // 精髓在正则 var arr = Str.match(isFilter ? /[1-9]\d{1,}/g : /\d{2,}/g); const result = arr.map(ele => ele); console.log(result); //连续数字的数组 for (let i = 0; i < result.length; i++) { if (result[i].length === 3) { finallyResult.push(result[i]); } } return finallyResult; // 连续的三个数字 }; console.log(getNum(str));
The text was updated successfully, but these errors were encountered:
const collectStrCount = (str) => { let reg = /\d{2,}/g; const resultList = []; while (res = reg.exec(str)) { reg.lastIndex++; resultList.push(res[0]) } return resultList.filter(item => item.length === 3); } console.log(collectStrCount(str2))
Sorry, something went wrong.
str.match(/(\d{3})/g) 啊哈?
const reg = /^.*(.)\1\1.*$/
No branches or pull requests
The text was updated successfully, but these errors were encountered: