728x90
์๋ฐ์คํฌ๋ฆฝํธ : ๋ฌธ์์ด ๋ฉ์๋ : match()
์ด๋ฒ ์๊ฐ์๋ ๋ฌธ์์ด ๋ฉ์๋์ธ match()์ ๋ํด ์์๋ณด๊ฒ ์ต๋๋ค! ๐
#1. match( )
match() ๋ฉ์๋๋ ๋ฌธ์์ด์ ๊ฒ์ํ๊ณ ๋ฐฐ์ด์ ๋ฐํํฉ๋๋ค.
! match( ) ์ฌ์ฉ ๋ฐฉ๋ฒ !
"๋ฌธ์์ด".math(๊ฒ์๊ฐ);
"๋ฌธ์์ด".math(์ ๊ท์ ํํ);
const str1 = "javascript reference";
const currentStr1 = str1.math("javascript"); // javascript
const currentStr2 = str1.math("reference"); // reference
const currentStr3 = str1.math("r"); // r
const currentStr4 = str1.math(/reference/); // reference
const currentStr5 = str1.math(/Reference/); // null
const currentStr6 = str1.math(/Reference/i); // reference
const currentStr7 = str1.math(/r/g); // ['r', 'r', 'r']
const currentStr8 = str1.math(/e/g); // ['e', 'e', 'e', 'e']
! point ! ๋์๋ฌธ์๋ฅผ ๊ตฌ๋ถํ๋ฉฐ ๋ฌธ์์ด์ ๊ฒ์๊ฐ์ด ์์ ๊ฒฝ์ฐ null์ด ๋ฐํ๋๋ค!
728x90
'JAVASCRIPT' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[JAVASCRIPT] ํจ์์ ์ ํ (4) | 2022.08.23 |
---|---|
[JAVASCRIPT] ๋ฌธ์์ด ๋ฉ์๋ : charAt( ) (1) | 2022.08.23 |
[JAVASCRIPT] ๋ฌธ์์ด ๋ฉ์๋ : search( ) (1) | 2022.08.23 |
[JAVASCRIPT] ๋ฌธ์์ด ๋ฉ์๋ : includes( ) (4) | 2022.08.18 |
[JAVASCRIPT] ๋ฌธ์์ด ๋ฉ์๋ : padStart( ) / padEnd( ) (3) | 2022.08.18 |
๋๊ธ