<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
	xmlns:media="http://search.yahoo.com/mrss/"
	>
<channel>
	<title>Comments on: Very Simple Regular Expressions (Starting with Numbers)</title>
	<atom:link href="http://www.knd.com.au/very-simple-regular-expressions-starting-with-numbers/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.knd.com.au/very-simple-regular-expressions-starting-with-numbers/</link>
	<description>KND&#039;s industry info, updates, tips and tricks.</description>
	<lastBuildDate>Thu, 09 Feb 2012 22:20:14 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: monkee</title>
		<link>http://www.knd.com.au/very-simple-regular-expressions-starting-with-numbers/comment-page-1/#comment-51</link>
		<dc:creator>monkee</dc:creator>
		<pubDate>Sat, 29 Nov 2008 01:25:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.knd.com.au/?p=348#comment-51</guid>
		<description>^([0-9]&#124;[0-9][0-9])$ is syntactically correct but can get unruly, a better way to represent this would be:

^[0-9]{1,2}$

We are introducing a new syntax element; the curly braces. This allows us to specify certain numerical combinations of the previous expression. The simplest of these is {n} where n is the number of times the expression is applied. You can though use combinations like {n,n+1) to denote more than one numerical match condition.

So imagine you were looking for any number between 0 and 99999, you could represent it this way:

^([0-9]&#124;[0-9][0-9]&#124;[0-9][0-9][0-9]&#124;[0-9][0-9][0-9][0-9]&#124;[0-9][0-9][0-9][0-9][0-9])$

or you could represent it this way:

^[0-9]{1,5}$

Which I think is more human readable.

It also offers certain flexibility.

Imagine you wanted numbers that contained leading zeroes between 00000 and 99999. You could then manipulate the expression:

^[0-9]{5}$

So when learning regular expressions, while simple syntax is good, a fuller understanding of the syntax can lead to SIMPLER regular expressions.</description>
		<content:encoded><![CDATA[<p>^([0-9]|[0-9][0-9])$ is syntactically correct but can get unruly, a better way to represent this would be:</p>
<p>^[0-9]{1,2}$</p>
<p>We are introducing a new syntax element; the curly braces. This allows us to specify certain numerical combinations of the previous expression. The simplest of these is {n} where n is the number of times the expression is applied. You can though use combinations like {n,n+1) to denote more than one numerical match condition.</p>
<p>So imagine you were looking for any number between 0 and 99999, you could represent it this way:</p>
<p>^([0-9]|[0-9][0-9]|[0-9][0-9][0-9]|[0-9][0-9][0-9][0-9]|[0-9][0-9][0-9][0-9][0-9])$</p>
<p>or you could represent it this way:</p>
<p>^[0-9]{1,5}$</p>
<p>Which I think is more human readable.</p>
<p>It also offers certain flexibility.</p>
<p>Imagine you wanted numbers that contained leading zeroes between 00000 and 99999. You could then manipulate the expression:</p>
<p>^[0-9]{5}$</p>
<p>So when learning regular expressions, while simple syntax is good, a fuller understanding of the syntax can lead to SIMPLER regular expressions.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

