[regex] PHP 정규표현식 패턴 24강 - \A (역슬래시 대문자A) : 문자열의 가장 처음 , \Z (역슬래시 제트) : 문자열의 가장 마지막
패턴 24 - \A : 가장 처음 줄의 시작 ^ : 각각의 줄의 시작 \Z : 가장 마지막 줄의 끝 $ : 각각의 줄의 끝
※ 주의; A와 Z는 대문자 사용해야 함.
Source
Ere iron was found or tree was hewn, When young was mountain under moon; Ere ring was made, or wrought was woe, It walked the forests long ago.
|
Case 1 - 가장 첫 줄의 시작 3개의 문자
Regular Expression: |
\A... |
---|
First match: |
Ere iron was found or tree was hewn, When young was mountain under moon; Ere ring was made, or wrought was woe, It walked the forests long ago. |
---|
All matches: |
Ere iron was found or tree was hewn, When young was mountain under moon; Ere ring was made, or wrought was woe, It walked the forests long ago.
|
---|
Case 2 - 가장 마지막 줄 끝 3개의 어떤 문자
Regular Expression: |
...\Z |
---|
First match: |
Ere iron was found or tree was hewn, When young was mountain under moon; Ere ring was made, or wrought was woe, It walked the forests long ago. |
---|
All matches: |
Ere iron was found or tree was hewn, When young was mountain under moon; Ere ring was made, or wrought was woe, It walked the forests long ago. |
---|
|
최신댓글