목록Algorithm (10)
말랑한 하루
자주 사용하는 정규표현식 관련 MDN 정리 var pattern = /pattern/flags; var regex = new RegExp(pattern); [ Methods ] //uselly test(): 문자열에 일치하는 부분 확인, return true/false; //unuselly exec(): 문자열에 일치하는 부분 탐색, return []/null; match(): 캡처그룹 포함 모든일치 확인, return []/null; matchAll(): 캡처그룹 포함 모든일치 확인, return 반복기 반환 //string search(): 문자열에 일치하는 부분 탐색, return index/-1; replace(): 문자열에 일치하는 부분 탐색, 첫 문자 대체문자열로 변환 replaceAll():..
※ JavaScript const getPermutations = function (arr, select) { const results = []; if (select === 1) return arr.map((el) => [el]); arr.forEach((fixed, index, origin) => { const rest = [...origin.slice(0, index), ...origin.slice(index + 1)]; const permutations = getPermutations(rest, select - 1); const attached = permutations.map((el) => [fixed, ...el]); results.push(...attached); }); return resul..