• 회원가입
  • 로그인
  • 구글아이디로 로그인

[regex] PHP 정규표현식 패턴 17강 - 수량자 ─ *? (별표 물음표), +? (덧셈 물음표), ?? (물음표 물음표) 의미

1,954  


 


 패턴 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 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 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 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 5  -  소문자 r 뒤에 어떤 문자가 최소 0 , 최대 1개  (즉, r 포함 1 ~ 2 글자)

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 6  -  소문자 r 뒤에 어떤 문자가 0개,  (즉, 오직 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

 

 

 

 

 

 

탐욕적 수량자 (Greedy quantifier)


의미:  가장 끝에 나오는 닫는 태그 앞까지 모두 매칭 검사

패턴 :  <div>.+</div>

매치:  <div>test</div><div>test2</div>

 

 

 

 

 

게으른 수량자 (Lazy quantifier)


의미 :  가장 처음 나오는 닫는 태그 앞까지만 선택해 매칭 검사  

패턴 :  <div>.+?</div>

매치:  <div>test</div><div>test1</div> 

 

 


분류 제목
PHP-서기 PHP 51 - 웹사이트크롤링 (= 사이트파싱) ★★★ (= 타사이트 특정부위 가져오기)
JS-서기 JS 8강 - for문 안쪽에 if문 사용 (= 행렬 표만들기 = 줄바꿈 = 줄바꾸기 = 줄변경 = 라인변…
regex PHP 정규표현식 패턴 26강 - (?!패턴) (소괄호 안 물음표 느낌표) : 뒤에 패턴 존재하면 무시, 존…
PHP7-서기 PHP7 32강 - 외부 SMTP 이용해 이메일 보내기 (= 네이버/구글 SMTP 설정법)
JS-바위 JS 18강 - 스크롤트리거 (Scrolltrigger) - 스크롤 애니메이션 구현
PHP-쩡원 PHP 기초 10강 - 게시판 만들기 - 코멘트 (=댓글) , 답댓글 (= 대댓글) 입력, 출력, 입출력
regex PHP 정규표현식 패턴 15강 - 수량자 ─ { } (중괄호) - 문자 반복 횟수 특정
PHP-생코 PHP 25강 - 조건문 논리연산자 (and (&&) , or (||)) ★★★
PHP2020-서기 PHP2020 4강 - 카카오맵 (MySQL 이용해 마커 표시 / 클러스터링 사용)
JS-서기 JS 12강 - 이벤트핸들러2 (event handler) - onload, onunload, / confi…
regex PHP 정규표현식 패턴 17강 - 수량자 ─ *? (별표 물음표), +? (덧셈 물음표), ?? (물음…
JS-엘리 JS 6강 - 클래스・오브젝트 차이점(class vs object), 객체지향 언어 클래스 정리 | (Jav…
서버 서버 - URL RewriteRule (= 라라이트룰 = URL주소치환 = URL주소변경)
regex PHP 정규표현식 패턴 9강 - [^ ] (대괄호안 꺽쇠) ─ 후보문자 제외한 모든 1글자로 된 문자
PHP-쩡원 PHP 기초 8강 - 게시판 만들기 (조회수증가, 날짜형식변경, 파일업로드, 파일명중복방지)
regex PHP 정규표현식 패턴 21강 - \d (역슬래시 소문자d) : 숫자 , \D (역슬래시 대문자D) : …
regex PHP 정규표현식 패턴 6강 - \ . (역슬래시 마침표) ─ 단순 문자열로서의 마침표 기호
regex PHP 정규표현식 패턴 22강 - \b (역슬래시 소문자b) : 워드(단어)의 경계
PHP-쩡원 PHP 기초 3강 - 회원가입 만들기 (테이블생성, 필드생성, 입력폼생성 / 쿠키, 암호화) (member,…
PHP-서기 php 10. 그외의 form관련 태그들 (input, textarea, select, option) ★★★…
1/35
목록
찾아주셔서 감사합니다. Since 2012