Metacharacters

These need to be escaped to be matched.

\ . ^ $ * + ? { } [ ] ( ) |

Escape sequences for pre-defined character classes

  • \d – a digit – [0-9]
  • \D – a nondigit – [^0-9]
  • \w – a word character (alphanumeric including underscore) – [a-zA-Z_0-9]
  • \W – a nonword character – [^a-zA-Z_0-9]
  • \s – a whitespace character – [ \t\n\r\f]
  • \S – a non-whitespace character – [^ \t\n\r\f]

Assertions

Assertions have zero width.

  • ^ – Matches the beginning of the line
  • $ – Matches the end of the line (or before a newline at the end)
  • \B – Matches everywhere except between a word character and non-word character
  • \b – Matches between word character and non-word character
  • \A – Matches only at the beginning of a string
  • \Z – Matches only at the end of a string or before a newline
  • \z – Matches only at the end of a string
  • \G – Matches where previous m//g left off

Minimal Matching Quantifiers

The quantifiers below match their preceding element in a non-greedy way.

  • *? – zero or more times
  • +? – one or more times
  • ?? – zero or one time
  • {n}?n times
  • {n,}? – at least n times
  • {n,m}? – at least n times but not more than m times

Courtesy : http://www.somacon.com/p127.php

Tagged with:
 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Set your Twitter account name in your settings to use the TwitterBar Section.