<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Php Development &#187; regular expressions</title>
	<atom:link href="http://www.maheshchari.com/tag/regular-expressions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.maheshchari.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 23 May 2010 05:10:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>regular expressions reference</title>
		<link>http://www.maheshchari.com/regular-expressions-reference/</link>
		<comments>http://www.maheshchari.com/regular-expressions-reference/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 23:11:20 +0000</pubDate>
		<dc:creator>mahesh chari</dc:creator>
				<category><![CDATA[PHP/mysql]]></category>
		<category><![CDATA[regular expressions]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=252</guid>
		<description><![CDATA[Regular Expressions Reference or Cheat   Sheet
The regular expression, as a pattern, can match all kinds of  text strings helping our web application validate, compare, sanitize data,  compute, decide , format , data extraction  etc. It can do simple or very complex string  manipulations. The list of possibilities is enormous when [...]]]></description>
			<content:encoded><![CDATA[<h2 >Regular Expressions Reference or Cheat   Sheet</h2>
<p>The regular expression, as a pattern, can match all kinds of  text strings helping our web application validate, compare, sanitize data,  compute, decide , format , data extraction  etc. It can do simple or very complex string  manipulations. The list of possibilities is enormous when it comes to what you  can achieve using regular expressions.Below table shows a quick referece to basic syntax , definations and examlple. </p>
<table width="100%" border="1" cellpadding="1" cellspacing="1">
<tr>
<td valign="top">
<p><strong>Character</strong></p>
</td>
<td valign="top">
<p align="center"><strong>Definition</strong></p>
</td>
<td valign="top">
<p align="center"><strong>Example</strong></p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">^</p>
</td>
<td valign="top">
<p>The pattern has to appear at the beginning of a string.</p>
</td>
<td valign="top">
<p><strong>^cat</strong> matches any string that    begins with cat</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">$</p>
</td>
<td valign="top">
<p>The pattern has to appear at the end of a string.</p>
</td>
<td valign="top">
<p><strong>cat$ </strong>matches any string that ends    with cat</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">.</p>
</td>
<td valign="top">
<p>Matches any character.</p>
</td>
<td valign="top">
<p><strong>cat.</strong> matches catT    and cat2 but not catty</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">[]</p>
</td>
<td valign="top">
<p>Bracket expression. Matches one of any characters    enclosed.</p>
</td>
<td valign="top">
<p><strong>gr[ae]y</strong> matches gray    or grey</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">[^]</p>
</td>
<td valign="top">
<p>Negates a bracket expression. Matches one of any    characters EXCEPT those enclosed.</p>
</td>
<td valign="top">
<p><strong>1[^02]</strong> matches 13    but not 10 or 12</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">[-]</p>
</td>
<td valign="top">
<p>Range. Matches any characters within the range.</p>
</td>
<td valign="top">
<p><strong>[1-9]</strong> matches any single digit    EXCEPT 0</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">?</p>
</td>
<td valign="top">
<p>Preceeding item must match one or zero times.</p>
</td>
<td valign="top">
<p><strong>colou?r</strong> matches color    or colour but not colouur</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">+</p>
</td>
<td valign="top">
<p>Preceeding item must match one or more times.</p>
</td>
<td valign="top">
<p><strong>be+</strong> matches be    or bee but not b</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">*</p>
</td>
<td valign="top">
<p>Preceeding item must match zero or more times.</p>
</td>
<td valign="top">
<p><strong>be*</strong> matches b    or be or beeeeeeeeee</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">()</p>
</td>
<td valign="top">
<p>Parentheses. Creates a substring or item that    metacharacters can be applied to</p>
</td>
<td valign="top">
<p><strong>a(bee)?t</strong> matches at    or abeet but not abet</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">{n}</p>
</td>
<td valign="top">
<p>Bound. Specifies exact number of times for the preceeding    item to match.</p>
</td>
<td valign="top">
<p><strong>[0-9]{3}</strong> matches any three digits</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">{n,}</p>
</td>
<td valign="top">
<p>Bound. Specifies minimum number of times for the    preceeding item to match.</p>
</td>
<td valign="top">
<p><strong>[0-9]{3,}</strong> matches any three or    more digits</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">{n,m}</p>
</td>
<td valign="top">
<p>Bound. Specifies minimum and maximum number of times for    the preceeding item to match.</p>
</td>
<td valign="top">
<p><strong>[0-9]{3,5}</strong> matches any three,    four, or five digits</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">|</p>
</td>
<td valign="top">
<p>Alternation. One of the alternatives has to match. <strong>&#8216;or&#8217;</strong> operater </p>
</td>
<td valign="top">
<p><strong>July (first|1st|1)</strong> will match July 1st but not July 2</p>
</td>
</tr>
<tr>
<td colspan="3">
<h3 align="center">POSIX Character Classes</h3>
</td>
</tr>
<tr>
<td valign="top">
<p><strong>Character</strong></p>
</td>
<td valign="top">
<p><strong>Definition</strong></p>
</td>
<td valign="top">
<p><strong>Example</strong></p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">[:alnum:]</p>
</td>
<td valign="top">
<p>alphanumeric character</p>
</td>
<td valign="top">
<p><strong>[[:alnum:]]{3}</strong> matches any three    letters or numbers, like 7Ds</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">[:alpha:]</p>
</td>
<td valign="top">
<p>alphabetic character, any case</p>
</td>
<td valign="top">
<p><strong>[[:alpha:]]{5}</strong> matches five    alphabetic characters, any case, like aBcDe</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">[:blank:]</p>
</td>
<td valign="top">
<p>space and tab</p>
</td>
<td valign="top">
<p><strong>[[:blank:]]{3,5}</strong> matches any    three, four, or five spaces and tabs</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">[:digit:]</p>
</td>
<td valign="top">
<p>digits</p>
</td>
<td valign="top">
<p><strong>[[:digit:]]{3,5}</strong> matches any    three, four, or five digits, like 3, 05, 489</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">[:lower:]</p>
</td>
<td valign="top">
<p>lowercase alphabetics</p>
</td>
<td valign="top">
<p><strong>[[:lower:]] </strong>matches a but not A</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">[:punct:]</p>
</td>
<td valign="top">
<p>punctuation characters</p>
</td>
<td valign="top">
<p><strong>[[:punct:]]</strong> matches ! or . or ,    but not a or 3</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">[:space:]</p>
</td>
<td valign="top">
<p>all whitespace characters, including newline and carriage    return</p>
</td>
<td valign="top">
<p><strong>[[:space:]] </strong>matches any space,    tab, newline, or carriage return</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">[:upper:]</p>
</td>
<td valign="top">
<p>uppercase alphabetics</p>
</td>
<td valign="top">
<p><strong>[[:upper:]]</strong> matches A but not a</p>
</td>
</tr>
<tr>
<td colspan="3">
<h3 align="center">Perl-Style Metacharacters</h3>
</td>
</tr>
<tr>
<td valign="top">
<p><strong>Character</strong></p>
</td>
<td valign="top">
<p><strong>Definition</strong></p>
</td>
<td valign="top">
<p><strong>Example</strong></p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">//</p>
</td>
<td valign="top">
<p>Default delimiters for pattern</p>
</td>
<td valign="top">
<p><em><strong>/colou?r/</strong></em> matches color or colour</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">i</p>
</td>
<td valign="top">
<p>Append to pattern to specify a case insensitive match</p>
</td>
<td valign="top">
<p><strong>/colou?r/i</strong> matches COLOR or Colour</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">\b</p>
</td>
<td valign="top">
<p>A word boundary, the spot between word (\w)    and non-word (\W) characters</p>
</td>
<td valign="top">
<p><strong>/\bfred\b/i </strong>matches Fred but not Alfred or Frederick</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">\B</p>
</td>
<td valign="top">
<p>A non-word boundary</p>
</td>
<td valign="top">
<p><strong>/fred\B/i</strong> matches Frederick but not Fred</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">\d</p>
</td>
<td valign="top">
<p>A single digit character,this is equivalent to the class <strong>[0-9]</strong>. </p>
</td>
<td valign="top">
<p><strong>/a\db/i </strong>matches a2b    but not acb</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">\D</p>
</td>
<td valign="top">
<p>A single non-digit character,this is equivalent to the class<strong> [^0-9]</strong>. </p>
</td>
<td valign="top">
<p><strong>/a\Db/i </strong>matches aCb    but not a2b</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">\n</p>
</td>
<td valign="top">
<p>The newline character. (ASCII 10)</p>
</td>
<td valign="top">
<p><strong>/\n/ </strong>matches a newline</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">\r</p>
</td>
<td valign="top">
<p>The carriage return character. (ASCII 13)</p>
</td>
<td valign="top">
<p><strong>/\r/</strong> matches a carriage return</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">\s</p>
</td>
<td valign="top">
<p>A single whitespace character,this is equivalent to the class<strong> [^ \t\n\r\f\v]</strong>. </p>
</td>
<td valign="top">
<p><strong>/a\sb/ </strong>matches a    b but not ab</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">\S</p>
</td>
<td valign="top">
<p>A single non-whitespace character,this is equivalent to the class <strong>[^ \t\n\r\f\v]</strong>. </p>
</td>
<td valign="top">
<p><strong>/a\Sb/ </strong>matches a2b    but not a b</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">\t</p>
</td>
<td valign="top">
<p>The tab character. (ASCII 9)</p>
</td>
<td valign="top">
<p><strong>/\t/</strong> matches a tab.</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">\w</p>
</td>
<td valign="top">
<p>A single word character &#8211; alphanumeric and underscore,this is equivalent to the class <strong>[a-zA-Z0-9_]</strong>. </p>
</td>
<td valign="top">
<p><strong>/\w/</strong> matches 1    or _ but not ?,</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center">\W</p>
</td>
<td valign="top">
<p>A single non-word character,this is equivalent to the class <strong>[^a-zA-Z0-9_]</strong>. </p>
</td>
<td valign="top">
<p><strong>/a\Wb/i </strong>matches a!b    but not a2b</p>
</td>
</tr>
</table>
<img src="http://www.maheshchari.com/?ak_action=api_record_view&id=252&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/regular-expressions-reference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
