정규표현식(Regular Expressions, Regex)은 문자열의 패턴을 정하는 방법이다. 예를들어, 이런걸 할 수 있다.

"로또 번호는 00부터 45사이에 있는 6개의 두자리수인데, 각 수는 쉼표로 구분된다"
이건
(([0-3]{1}[0-9]{1})[,]{1}|([4]{1}[0-5]{1}[,]{1})){5}([0-3]{1}[0-9]{1}|[4]{1}[0-5]{1}){1}
이렇게 나타내면 된다. (다만 이 표현식으로는 중복된건 못 걸러낸다.)

정규표현식을 테스트 해보고 싶으면 아래 웹 사이트에서 간단히 해볼 수 있다.
http://regexpal.com/

이 얘기를 왜 하냐면, 만화를 하나 소개하려고...

이 만화는 CCL에 의해서 사용된다.
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial 2.5 License.
This means you're free to copy and share these comics (but not to sell them). More details.

원본 : http://xkcd.com/208/

알면 재밌다.
by snowall 2009. 10. 1. 02:53