리눅스 쉘 스크립트 학습 - 정규 표현식 - 패턴 매칭

Purple·2022년 10월 12일
0

리눅스 쉘 스크립트

목록 보기
26/53

패턴 매칭 - 정규 표현식 연습 사이트
https://regexr.com/3bd56

원하는 문자열(Welcome)이 line의 제일 처음에 위치하는 경우 매칭

  • ^ : Beginning. Matches the beginning of the string. or the beginning of a line if the multiline flag (m) is enabled.
  • 메타문자 은 NOT의 뜻과 라인의 처음을 나타내는 두가지 기능으로 사용된다.
  • 메타문자 []안에서 사용되는 경우, NOT의 의미를 갖는다.

원하는 문자열(Welcome)이 line의 제일 마지막에 위치하는 경우를 매칭

  • $ : End. Matches the end of the string, or the end of a line if the multiline flag (m) is enabled.

원하는 문자열(Welcome)이 line을 기준으로, 나오지 않을때까지 매칭

  • . : Dot.Macthes any character except line breaks.
  • "+" : Quantifier. Match 1 or more of the preceding token.
  • 여기서의 +를 greedy 수량자라고 한다. 따라서 가장 큰 범위로 매칭이 된나.

원하는 문자열(Welcome)이 나왈때마다, 매칭

  • ? : Lazy. Makes the preceding quantifier lazy, causing it to match as few characters as possible.
  • 여기서의 ?를 lazy 수량자라고 한다. 따라서 가장 좁은 범위로 매칭이 된다.
profile
안녕하세요.

0개의 댓글