728x90
๋ฐ์ํ
match() : ๋ฌธ์์ด์ ๊ฒ์(์ ๊ท์) : ๋ฐํ(๋ฐฐ์ด)
match() ๋ฉ์๋๋ ๋ฌธ์์ด(์ ๊ท์)์ ๊ฒ์ํ๊ณ ์ผ์นํ๋ ๊ฒฐ๊ณผ๊ฐ์ ๋ฐฐ์ด๋ก ๋ฐํํฉ๋๋ค.
"๋ฌธ์์ด".match(์ฐพ์ ๋ฌธ์์ด, ๋ณ๊ฒฝํ ๋ฌธ์์ด)
"๋ฌธ์์ด".match(์ ๊ท์)
"๋ฌธ์์ด".match(์ ๊ท์, ๋ณ๊ฒฝํ ๋ฌธ์์ด)
"๋ฌธ์์ด".match(์ ๊ท์)
"๋ฌธ์์ด".match(์ ๊ท์, ๋ณ๊ฒฝํ ๋ฌธ์์ด)
const str1 = "javascript reference";
const currentStr1 = str1.match('javascript'); //['javascript', index: 0, input: 'javascript reference', groups: undefined]
const currentStr2 = str1.match('reference'); //['reference', index: 11, input: 'javascript reference', groups: undefined]
const currentStr3 = str1.match('r'); //['r', index: 6, input: 'javascript reference', groups: undefined]
const currentStr4 = str1.match(/reference/); //['reference', index: 11, input: 'javascript reference', groups: undefined]
const currentStr5 = str1.match(/Reference/); //null
const currentStr6 = str1.match(/Reference/i); //['reference', index: 11, input: 'javascript reference', groups: undefined]
const currentStr7 = str1.match(/r/g); //['r','r','r']
const currentStr8 = str1.match(/e/g); //['e','e','e','e']
728x90
๋ฐ์ํ
'์๋ฐ์คํฌ๋ฆฝํธ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
ํจ์ ์ดํดํ๊ธฐ 2 (5) | 2022.08.22 |
---|---|
charAt() (7) | 2022.08.22 |
search() (5) | 2022.08.22 |
includes() (5) | 2022.08.17 |
padStart() / padEnd() (5) | 2022.08.17 |
๋๊ธ