2008/04/10 17:13
Character literals

/a/ Mary had a little lamb. And everywhere that Mary went, the lamb was sure to go.
/Mary/
Mary had a little lamb. And everywhere that Mary went, the lamb was sure to go.


"Escaped" characters literals

/.*/ Special characters must be escaped.*
/\.\*/
Special characters must be escaped.*

Positional special characters

/^Mary/ Mary had a little lamb. And everywhere that Mary went, the lamb was sure to go.
 /Mary$/ Mary had a little lamb. And everywhere that Mary went, the lamb was sure to go.


The "wildcard" character

/.a/ Mary had a little lamb. And everywhere that Mary went, the lamb was sure to go.

Character classes

/[a-z]a/ Mary had a little lamb. And everywhere that Mary went, the lamb was sure to go.


Complement operator

/[^a-z]a/ Mary had a little lamb. And everywhere that Mary went, the lamb was sure to go.


Alternation of patterns

/cat|dog|bird/ The pet store sold cats, dogs, and birds.
/=first|second=/
=first first= # =second second= # =first= # =second=
/(=)(first)|(second)(=)/
=first first= # =second second= # =first= # =second=
/=(first|second)=/
=first first= # =second second= # =first= # =second=

출처 : http://gnosis.cx/publish/programming/regular_expressions.html

'IT' 카테고리의 다른 글

XP Themes  (0) 2008/10/06
vi 편집기  (0) 2008/06/11
Grep 편리한 옵션들  (0) 2008/04/10
Regular Expression  (2) 2008/04/10
Process Explorer & Autoruns  (2) 2008/02/18
Recommended Add-ons for Internet Explorer  (0) 2008/02/13
쉘 프로그래밍 강좌  (3) 2007/05/08
성능 데이터 모델링 - 정규화를 통한 성능 향상  (2) 2005/03/02
Posted by 형준군