728x90
반응형
![](https://blog.kakaocdn.net/dn/cwwE1j/btrLgTJw30R/dzOPXQjek28Tm1yYyGaiL1/img.jpg)
match()
match() 메서드는 문자열을 검색하고 배열을 반환합니다.
"문자열".match("검색값")
"문자열".match(정규식 표현)
const str1 = "javascript reference";
const currentStr1 = str1.match("javascript"); //javascript
const currentStr2 = str1.match("reference"); //reference
const currentStr3 = str1.match("r"); //r
const currentStr4 = str1.match(/reference/); //reference
const currentStr5 = str1.match(/Reference/); //null
const currentStr6 = str1.match(/Reference/i); //reference
const currentStr7 = str1.match(/r/g); //['r', 'r', 'r']
const currentStr8 = str1.match(/e/g); //['e', 'e', 'e', 'e']
728x90
반응형
'javascript' 카테고리의 다른 글
JavaScript search() (3) | 2022.08.22 |
---|---|
JavaScript charAt(), charCodeAt() (3) | 2022.08.22 |
JavaScript toUpperCase() / toLowerCase() (2) | 2022.08.17 |
JavaScript trim() / trimStart() / trimEnd() (2) | 2022.08.17 |
JavaScript concat() (2) | 2022.08.17 |