π§ codingtest/μ κ·ννμ(regexp)
07. νμ ννμ μ¬μ©νκΈ°
awesomeyelim
2022. 9. 3. 20:08
728x90
- νμ ννμ(Subexpression)(
()
)μ μ¬μ©νμ¬ μ¬λ¬ ννμμ μ΄λ»κ² λ¬Άλμ§ μμ보μ!
νμ ννμ μ΄ν΄
μμλΉκ΅
- μμ
1920-06-07 the cat scattered his food all over room,
λμ μ | λ§€μΉκ²°κ³Ό |
1. {2,} |
1920-06-07 the cat scattered his food all over room, |
2. ( ){2,} |
1920-06-07 the cat scattered his food all over room, |
3.19|20\d{2} | 1920-06-07 the cat scattered his food all over room, |
4. (19|20)\d{2} | 1920-06-07 the cat scattered his food all over room, |
π 1λ² νλͺ©μ μμ μλ μΈλ―Έμ½λ‘ μ λμμΌλ‘ λ°λ³΅(;) λκΈ°λλ¬Έμ λ§€μΉμ΄ x
π 3λ² νλͺ©μ '|'(OR μ°μ°μ)λ₯Ό μ¬μ©νμλ€(19 λλ 20 κ³Ό μΌμΉ)νλ©° νμννμ μ§μ μ μν΄μ£ΌμκΈ° λλ¬Έμ 19
λ§ μ§μ λ¨
π κ°λ
μ±μ λμ΄κΈ° μν νμννμ(()
) μ¬μ©λ μΆμ² π
μ€μ²©λ νμ ννμ
IP μΆμ ν¨ν΄
-
- λͺ¨λ ν μ리 νΉμ λ μ리 μ«μ ->
(\d{1,2})
- 1λ‘ μμνλ λͺ¨λ μΈ μ리 μ«μ ->
(1\d{2})
- 2λ‘ μμνλ©΄μ λλ²μ§Έ μ리 μ«μκ° 0λΆν° 4μ¬μ΄μ λͺ¨λ μΈμ리 μ«μ ->
(2[0-4]\d)
- 25λ‘ μμνλ©΄μ μΈλ²μ§Έ μ리 μ«μκ° 0λΆν° 5μ¬μ΄μ λͺ¨λ μΈμ리 μ«μ ->
(25[0-5])
- λͺ¨λ ν μ리 νΉμ λ μ리 μ«μ ->
- μμ
Yelim.com [`12.159.46.200`] with 32bytes of data
λμ μ | μ€νκ²°κ³Ό |
(((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(\d{2})|(2[0-4]\d)|(25[0-5])) |
Yelim.com [ 12.159.46.200 ] with 32bytes of data |