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

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

1,747  


 


 패턴 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 52 - PDF 만들기1. 기본환경 설정
PHP-서기 PHP 51 - 웹사이트크롤링 (= 사이트파싱) ★★★ (= 타사이트 특정부위 가져오기)
PHP-서기 PHP 50 - vscode 이용한 ftp서버상파일 직접 편집/저장
서버 서버 - URL RewriteRule (= 라라이트룰 = URL주소치환 = URL주소변경)
React React - 리액트 무료강의 (재생: 5시간 5분 33초)
PHP-쩡원 PHP 중급 2강 - 쇼핑몰 (회원가입, 로그인, 로그아웃. 기타) 페이지
PHP-쩡원 PHP 중급 1강 - 쇼핑몰 (Root 디렉터리 , index파일, mysql파일 + 회원가입 페이지) 만…
PHP-쩡원 PHP 기초 12강 - 게시판 만들기 - 자주하는 코딩실수 (※ 기초과정 종강)
PHP-쩡원 PHP 기초 11강 - 게시판 만들기 - 코멘트(댓글, 답글) , 게시글검색
PHP-쩡원 PHP 기초 10강 - 게시판 만들기 - 코멘트 (=댓글) , 답댓글 (= 대댓글) 입력, 출력, 입출력
PHP-쩡원 PHP 기초 9강 - 게시판 만들기 (파일수정, 파일삭제, 스마트에디터달기)
PHP-쩡원 PHP 기초 8강 - 게시판 만들기 (조회수증가, 날짜형식변경, 파일업로드, 파일명중복방지)
PHP-쩡원 PHP 기초 7강 - 게시판 만들기 (글수정, 글삭제, 삭제확인, 목록링크)
PHP-쩡원 PHP 기초 6강 - 게시판 만들기 (페이징)
PHP-쩡원 PHP 기초 5강 - 게시판 만들기 (테이블, 필드, 입력폼, 생성, 수정, 삭제, 변경) (alter, u…
PHP-쩡원 PHP 기초 4강 - 회원가입 만들기 (폼입력값 유효성검사) (Form Validation)
PHP-쩡원 PHP 기초 3강 - 회원가입 만들기 (테이블생성, 필드생성, 입력폼생성 / 쿠키, 암호화) (member,…
PHP-쩡원 PHP 기초 2강 - 게시판 만들기 (테이블생성, 필드생성, 입력폼생성) (board, table, fiel…
PHP-쩡원 PHP 기초 1강 - APMSETUP 설치 + PhpMyAdmin 설치
PHP-쩡원 PHP 기초 0강 - PHP 입문 (기본 구문, 연산자, PHP와 HTML 혼용)
10/35
목록
찾아주셔서 감사합니다. Since 2012