
정규표현식(str.matchAll(regex))에서 옵션을 설정하는 방법은 다음과 같습니다.
- str.matchAll(regex) 함수는 모든 매치를 반환하는 반면, str.match(regex) 함수는 첫 번째 매치를 반환합니다.
- str.matchAll(regex) 함수는 iterator를 반환하므로, matches를 콘솔에 출력하기 전에 matches.next().value를 사용하여 값을 추출해야 합니다.
정규표현식(str.matchAll(regex))에서 옵션을 설정하는 방법은 없습니다. 옵션을 설정하기 위해서는 str.match(regex) 함수를 사용해야 합니다.
str.matchAll(regex) 함수를 사용하여 문자열에서 패턴을 찾으려면, matches를 콘솔에 출력하기 전에 matches.next().value를 사용하여 값을 추출해야 합니다.
#hostingforum.kr
javascript
const regex = /d+/g;
const str = "123abc456def789";
const matches = str.matchAll(regex);
console.log(matches.next().value); // ["123", "456", "789"]
위 코드를 실행하면 matches의 값이 ["123", "456", "789"]로 출력됩니다.
2025-06-20 10:56