Skip to content

Diwoni/regexp-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

μ •κ·œν‘œν˜„μ‹ (RegExp)

μ •κ·œμ‹, Regular Expression

μ—­ν• 

  • 문자 검색(search)
  • 문자 λŒ€μ²΄ (replace)
  • 문자 μΆ”μΆœ (extract)

ν…ŒμŠ€νŠΈ μ‚¬μ΄νŠΈ

https://regexr.com/

μ •κ·œμ‹ 생성

//μƒμ„±μž
new RegExp('ν‘œν˜„','μ˜΅μ…˜')
new RegExp('[a-z]', 'gi')

//λ¦¬ν„°λŸ΄
/ν‘œν˜„/μ˜΅μ…˜
/[a-z]/gi

예제문자

const str = `
010-1234-5678
[email protected]
http://www.omdbapi.com/?apikey=7035c60c&s=frozen
The quick brown fox jumps over the lazy dog.
abbcccdddd
`

λ©”μ†Œλ“œ

λ©”μ†Œλ“œ 문법 μ„€λͺ…

test | μ •κ·œμ‹.test(λ¬Έμžμ—΄) | 일치 μ—¬λΆ€(Boolean) λ°˜ν™˜ match | λ¬Έμžμ—΄.match(μ •κ·œμ‹) | μΌμΉ˜ν•˜λŠ” 문자의 λ°°μ—΄ λ°˜ν™˜ replace | λ¬Έμžμ—΄.replace(μ •κ·œμ‹,λŒ€μ²΄ν•  문자) | λ¬Έμžμ—΄ λŒ€μ²΄

ν”Œλž˜κ·Έ(μ˜΅μ…˜)

ν”Œλž˜κ·Έ μ„€λͺ…
g λͺ¨λ“  문자 일치(global)
i μ˜μ–΄ λŒ€μ†Œλ¬Έμžλ₯Ό ꡬ뢄 μ•Šκ³  일치 (ignore case)
m μ—¬λŸ¬μ€„ 일치 (multi line)

νŒ¨ν„΄(ν‘œν˜„)

νŒ¨ν„΄ μ„€λͺ…
^ab 쀄(Line) μ‹œμž‘μ— μžˆλŠ” ab와 일치
ab$ 쀄(Line) 끝에 μžˆλŠ” ab와 일치

. | μž„μ˜μ˜ ν•œ λ¬Έμžμ™€ 일치 a|b | a λ˜λŠ” b와 일치 ab? | b κ°€ μ—†κ±°λ‚˜ b와 일치

{3} | 3개 연속 일치 {3,} | 3개 이상 연속 일치 {3,5} | 3개 이상 5개 μ΄ν•˜ 연속 일치

[abc] | a λ˜λŠ” b λ˜λŠ” c [a-z] | aλΆ€ν„° z μ‚¬μ΄μ˜ 문자 ꡬ간에 일치 (μ˜μ–΄ μ†Œλ¬Έμž) [A-Z] | AλΆ€ν„° Z μ‚¬μ΄μ˜ 문자 ꡬ간에 일치 (μ˜μ–΄ λŒ€λ¬Έμž) [0-9] | 0λΆ€ν„° 9 μ‚¬μ΄μ˜ 문자 ꡬ간에 일치 (숫자) [κ°€-힣] | κ°€λΆ€ν„° 힣 μ‚¬μ΄μ˜ 문자 ꡬ간에 일치(ν•œκΈ€)

\w | 63개 문자(Word, λŒ€μ†Œμ˜λ¬Έ52개 + 숫자10개 + _) 에 일치 \b | 63개 λ¬Έμžμ— μΌμΉ˜ν•˜μ§€ μ•ŠλŠ” 문자 경계 (Boundary) = 특수기호 \d | 숫자(Digit)에 일치 \s | 곡백(Space, Tab λ“±)에 일치 (?=) | μ•žμͺ½ 일치 (Lookahead) (?<=>) | λ’€μͺ½ 일치 (Lookbehind)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors