const escape = (text, flag = 0) => { const replaceAll = (text, pattern, func) => { const…
- User
const escape = (text, flag = 0) => { const replaceAll = (text, pattern, func) => { const findAllIndex = (str, pattern) => { const indexList = [0]; const regex = new RegExp(pattern, 'gm'); let match; while ((match = regex.exec(str)) !== null) { if (match[1] !== undefined) { const start = match.index; const end = regex.lastIndex; indexList.push(start, end); } } indexList.push(str.length); return indexList; };
ubah ke python
- Assistant