VIDEO
패턴 17 - * , + , ? 패턴 뒤에 ?가 붙으면 해당 의미의 최소값만 선택됨.
Source
One ring to bring them all and in the darkness bind them
Case 1 - 소문자 r 뒤에 어떠한 문자든 0개 이상
Regular Expression:
r.*
First match:
One ring to bring them all and in the darkness bind them
All matches:
One ring to bring them all and in the darkness bind them
Case 2 - 소문자 r 뒤에 어떠한 문자가 딱 0개, 즉, 오직 r만 선택
Regular Expression:
r.*?
First match:
One r ing to bring them all and in the darkness bind them
All matches:
One r ing to b r ing them all and in the da r kness bind them
Case 3 - 소문자 r 뒤에 공백 포함 어떠한 문자든 최소 1개 이상 (즉, r 뒤 전부)
Regular Expression:
r.+
First match:
One ring to bring them all and in the darkness bind them
All matches:
One ring to bring them all and in the darkness bind them
Case 4 - 소문자 r 뒤에 어떠한 문자든 1개만, (즉, r 포함 2글자)
Regular Expression:
r.+?
First match:
One ri ng to bring them all and in the darkness bind them
All matches:
One ri ng to b ri ng them all and in the da rk ness bind them
Case 5 - 소문자 r 뒤에 어떤 문자가 최소 0 , 최대 1개 (즉, r 포함 1 ~ 2 글자)
Regular Expression:
r.?
First match:
One ri ng to bring them all and in the darkness bind them
All matches:
One ri ng to b ri ng them all and in the da rk ness bind them
Case 6 - 소문자 r 뒤에 어떤 문자가 0개, (즉, 오직 r만 선택)
Regular Expression:
r.??
First match:
One r ing to bring them all and in the darkness bind them
All matches:
One r ing to b r ing them all and in the da r kness bind them
탐욕적 수량자 (Greedy quantifier)
의미: 가장 끝에 나오는 닫는 태그 앞까지 모두 매칭 검사 패턴 : <div>.+</div> 매치: <div>test</div><div>test2</div>
게으른 수량자 (Lazy quantifier)
의미 : 가장 처음 나오는 닫는 태그 앞까지만 선택해 매칭 검사 패턴 : <div>.+? </div> 매치: <div>test</div> <div>test1</div>
주소 복사
랜덤 이동
최신댓글