'Regular Expressions'에 해당되는 글 1건

  1. 2008/04/10 Regular Expression (2)
IT2008/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
Posted by 형준군