const extractStr = (str) => { let result = [], pattern = /\:+(\w*)\.+/g, temp = null while(temp = pattern.exec(str)){ result.push(temp[1]) } return result}
例如:extractStr('My name is:Jerry. My age is:12.') // => ['Jerry', '12']
本文共 299 字,大约阅读时间需要 1 分钟。
const extractStr = (str) => { let result = [], pattern = /\:+(\w*)\.+/g, temp = null while(temp = pattern.exec(str)){ result.push(temp[1]) } return result}
例如:extractStr('My name is:Jerry. My age is:12.') // => ['Jerry', '12']
转载于:https://www.cnblogs.com/love314159/p/7651433.html