한땀한땀 정성들인 코딩
perl 문자열 일치 본문
반응형
$long = "tell me what\'s up"
if( $long =~ /hat/ ) # 'hat'도 가능하지만 //쓰는 것에 습관을 들이자.
정규식이란?
패턴을 한 문자열안에 설정시켜주는 식 ( sql쿼리 언어의 %,_등과 비슷하다. )
/h.t/ : hat,hot,hut,hit
/h*t/ : ht,hat,hot,hooot,hooooooo.....t
/h+t/ : +는 1과 그이상 ( *는 0과 그이상 )
/h?t/ : 0또는 1개
^.e : he,me,regard
t.e$ : toe, necktie
character class
h[eao]y : hey,hay,hoy
[a-z] : -는 범위
[a-z]+ : 소문자가 하나 또는 여러개
대소문자 무시
/hat/i # 뒤에 i붙이면 무시 "ignore case"
/clean|dirty/ #clean or dirty
(eg | le)g #egg leg
ba(na)+ # bana,banana,bananananananana
반응형
'언어 > perl' 카테고리의 다른 글
문자열 찾아 봐꾸기!!! (0) | 2017.01.03 |
---|---|
perl의 반복실행 (0) | 2017.01.03 |
perl의 명령행 인수 @ARGV (0) | 2017.01.03 |
perl의 디렉토리 다루기 (0) | 2017.01.03 |
perl의 파일다루기 (0) | 2017.01.03 |