Pcretest/pcre2test

From 탱이의 잡동사니
Jump to navigation Jump to search

Overview

pcre 사용법 내용 정리.

Basic

pcretest/pcre2test

작성한 정규 표현식을 쉽게 테스트해볼 수 있게 해주는 굉장히 유용한 툴이다. 확인하고자하는 정규 표현식을 먼저 입력하고, 샘플 문장을 입력하면 된다. pcre-10.0 부터는 pcre2 로 부른다.

$ pcretest 
PCRE version 7.8 2008-09-05
  re> "(.+): (.+)"
data> Message: Unable to add interface: Already there
 0: Message: Unable to add interface: Already there
 1: Message: Unable to add interface
 2: Already there

$ pcre2test 
PCRE2 version 10.10 2015-03-06
  re> "(.+): (.+)" 
data> Message: Unable to add interface: Already there
 0: Message: Unable to add interface: Already there
 1: Message: Unable to add interface
 2: Already there

애석하지만, 현재 우분투에서는 pcretest 프로그램을 사용할 수 없다. 원래는 libpcre3 패키지에 포함되어 있었던 것 같은데, 2011년부터 패키징에서 빠지게되었던 것. 사람들이 이에 대해서 많이 요청하고는 있지만 현재까지 추가되지 않고있는 상황이다(2015.11)<ref>https://bugs.launchpad.net/ubuntu/+source/pcre3/+bug/889073</ref>. 아무튼 이런 이유로 우분투에서 pcretest 를 사용할 수 없지만, 대안으로 pcre2test 소스코드를 다운받아 설치하는 방법이 있다. 다음 링크에서 적당한 소스 패키지를 다운받아서 설치하면 된다.

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

See also

References

<references />