๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ

match()

by Youcodein 2022. 8. 22.
728x90
๋ฐ˜์‘ํ˜•

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

๋Œ“๊ธ€