satishgaudo.com

Understanding technology

Regular Expressions:Examples

  * .at matches any three-character string ending with "at",
including "hat", "cat", and "bat".

* [hc]at matches "hat" and "cat".

* [^b]at matches all strings matched by .at except "bat".

* ^[hc]at matches "hat" and "cat", but only at the beginning
of the string or line.

* [hc]at$ matches "hat" and "cat", but only at the end
of the string or line.

* \[.\] matches any single character surrounded by "[" and "]"
since the brackets are escaped, for example: "[a]" and "[b]".

* [hc]+at matches "hat", "cat", "hhat", "chat", "hcat",
"ccchat", and so on, but not "at".

* [hc]?at matches "hat", "cat", and "at".

* [hc]*at matches "hat", "cat", "hhat", "chat", "hcat", "ccchat",
"at", and so on.

* cat|dog matches "cat" or "dog".

For detail explanation: http://en.wikipedia.org/wiki/Regular_expression

Bookmark and Share
Categories: PHP - linux
*