<?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>Cultivate Web Design Melbourne - Development Blog &#187; regex</title>
	<atom:link href="http://cultivatewebdesign.com.au/blog/tag/regex/feed/" rel="self" type="application/rss+xml" />
	<link>http://cultivatewebdesign.com.au/blog</link>
	<description></description>
	<lastBuildDate>Thu, 12 Aug 2010 04:16:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Regular expression to remove in-line styles</title>
		<link>http://cultivatewebdesign.com.au/blog/regular-expression-to-remove-in-line-styles/</link>
		<comments>http://cultivatewebdesign.com.au/blog/regular-expression-to-remove-in-line-styles/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 04:16:42 +0000</pubDate>
		<dc:creator>Chris Gunn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[remove inline styles]]></category>

		<guid isPermaLink="false">http://cultivatewebdesign.com.au/blog/?p=202</guid>
		<description><![CDATA[style=&#34;[a-zA-Z0-9_;:%# -]+&#34;]]></description>
			<content:encoded><![CDATA[<pre class="brush: plain;">
style=&quot;[a-zA-Z0-9_;:%# -]+&quot;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://cultivatewebdesign.com.au/blog/regular-expression-to-remove-in-line-styles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easy forms building with regular expressions</title>
		<link>http://cultivatewebdesign.com.au/blog/easy-forms-building-with-regular-expressions/</link>
		<comments>http://cultivatewebdesign.com.au/blog/easy-forms-building-with-regular-expressions/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 13:00:47 +0000</pubDate>
		<dc:creator>Chris Gunn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[save form values]]></category>

		<guid isPermaLink="false">http://cultivatewebdesign.com.au/blog/?p=100</guid>
		<description><![CDATA[Hate if or love it, forms are a daily part of a developers life. In this post I will show you a few ways to ease the pain. Say we have this, &#60;form method=&#34;post&#34;&#62; Member id:&#60;input id=&#34;memberid&#34; /&#62;&#60;br /&#62; First name:&#60;input id=&#34;firstname&#34; /&#62;&#60;br /&#62; Last name:&#60;input id=&#34;lastname&#34; /&#62;&#60;br /&#62; Phone:&#60;input id=&#34;phone&#34; /&#62;&#60;br /&#62; Email:&#60;input id=&#34;email&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>Hate if or love it, forms are a daily part of a developers life. In this post I will show you a few ways to ease the pain.</p>
<p>Say we have this,</p>
<pre class="brush: xml;">
&lt;form method=&quot;post&quot;&gt;
	Member id:&lt;input id=&quot;memberid&quot; /&gt;&lt;br /&gt;
	First name:&lt;input id=&quot;firstname&quot; /&gt;&lt;br /&gt;
	Last name:&lt;input id=&quot;lastname&quot; /&gt;&lt;br /&gt;
	Phone:&lt;input id=&quot;phone&quot; /&gt;&lt;br /&gt;
	Email:&lt;input id=&quot;email&quot; /&gt;&lt;br /&gt;
	&lt;input type=&quot;submit&quot; /&gt;
&lt;/form&gt;
</pre>
<p>And we want to end up like this one below:</p>
<pre class="brush: xml;">
&lt;form method=&quot;post&quot;&gt;
	Member id:&lt;input name=&quot;memberid&quot; value=&quot;&lt;?=$_POST['memberid']?&gt;&quot; id=&quot;memberid&quot; /&gt;&lt;br /&gt;
	First name:&lt;input name=&quot;firstname&quot; value=&quot;&lt;?=$_POST['firstname']?&gt;&quot; id=&quot;firstname&quot; /&gt;&lt;br /&gt;
	Last name:&lt;input name=&quot;lastname&quot; value=&quot;&lt;?=$_POST['lastname']?&gt;&quot; id=&quot;lastname&quot; /&gt;&lt;br /&gt;
	Phone:&lt;input name=&quot;phone&quot; value=&quot;&lt;?=$_POST['phone']?&gt;&quot; id=&quot;phone&quot; /&gt;&lt;br /&gt;
	Email:&lt;input name=&quot;email&quot; value=&quot;&lt;?=$_POST['email']?&gt;&quot; id=&quot;email&quot; /&gt;&lt;br /&gt;
	&lt;input type=&quot;submit&quot; /&gt;
&lt;/form&gt;
</pre>
<p>So what do we do? We ask a little help from our mate, regEx.<br />
We search for this</p>
<pre class="brush: plain;"> id=&quot;([a-z0-9_-]+)&quot; </pre>
<p>and replace with this</p>
<pre class="brush: plain;"> name=&quot;$1&quot; id=&quot;$1&quot; </pre>
<p>. Now for values search for</p>
<pre class="brush: plain;"> name=&quot;([a-z0-9_-]+)&quot; </pre>
<p>and replace with</p>
<pre class="brush: plain;"> name=&quot;$1&quot; value=&quot;&lt;?=$_POST['$1']?&gt;&quot; </pre>
<p>and bang! It&#8217;s done!</p>
<p>Now a little tip on how to convert those nasty</p>
<pre class="brush: xml;">
&lt;select name=&quot;country&quot;&gt;
	&lt;option value=&quot;Australia&quot;&gt;Australia&lt;/option&gt;
	&lt;option value=&quot;Austria&quot;&gt;Austria&lt;/option&gt;
	&lt;option value=&quot;Bahamas&quot;&gt;Bahamas&lt;/option&gt;
	....
&lt;/select&gt;
</pre>
<p>to</p>
<pre class="brush: xml;">
&lt;select name=&quot;country&quot;&gt;
	&lt;option value=&quot;Australia&quot; &lt;?=$_POST['country']=='Australia'?' selected ':''?&gt;&gt;Australia&lt;/option&gt;
	&lt;option value=&quot;Austria&quot; &lt;?=$_POST['country']=='Austria'?' selected ':''?&gt;&gt;Austria&lt;/option&gt;
	&lt;option value=&quot;Bahamas&quot; &lt;?=$_POST['country']=='Bahamas'?' selected ':''?&gt;&gt;Bahamas&lt;/option&gt;
	....
&lt;/select&gt;
</pre>
<p>All you have to do is to replace</p>
<pre class="brush: plain;">&lt;option value=&quot;([A-Za-z0-9_ -]+)&quot;&gt;([A-Za-z0-9_ -]+)&lt;/option&gt;</pre>
<p>with</p>
<pre class="brush: plain;">&lt;option value=&quot;$1&quot; &lt;?=$_POST['country']=='$1'?' selected ':''?&gt;&gt;$2&lt;/option&gt;</pre>
<p>Now only if designing forms with out tables was this easy <img src='http://cultivatewebdesign.com.au/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://cultivatewebdesign.com.au/blog/easy-forms-building-with-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

