<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>regex &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/regex/</link>
	<description>Feed of posts on WordPress.com tagged "regex"</description>
	<pubDate>Sun, 29 Nov 2009 19:52:28 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Apex Validate Email Regex]]></title>
<link>http://pjflynn.wordpress.com/2009/11/26/apex-validate-email-regex/</link>
<pubDate>Thu, 26 Nov 2009 15:31:56 +0000</pubDate>
<dc:creator>pjflynn</dc:creator>
<guid>http://pjflynn.wordpress.com/2009/11/26/apex-validate-email-regex/</guid>
<description><![CDATA[Create a validation of type Regular Expression Expression 1 = ITEM_ID Expression 2 = ^[a-zA-Z0-9]{1}]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Create a validation of type Regular Expression</p>
<p>Expression 1 = ITEM_ID</p>
<p>Expression 2 = ^[a-zA-Z0-9]{1}[a-zA-Z0-9\.\-]{1,}@[a-zA-Z0-9]{1}[a-zA-Z0-9\.\-]{1,}\.{1}[a-zA-Z]{2,4}$</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Matching wildcard from database against post details]]></title>
<link>http://ashfaqasp.wordpress.com/2009/11/19/matching-wildcard-from-database-with-post-details/</link>
<pubDate>Thu, 19 Nov 2009 03:43:48 +0000</pubDate>
<dc:creator>Ashfaq</dc:creator>
<guid>http://ashfaqasp.wordpress.com/2009/11/19/matching-wildcard-from-database-with-post-details/</guid>
<description><![CDATA[I had to fetch data from database foulword table which can contain words or wildcard word and had to]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I had to fetch data from database foulword table which can contain words or wildcard word and had to compare those with post details field. Following are the code i came up with. I am saving this for my future purpose and also for those who are searching for same kind of thing.</p>
<p>
<code><br />
/// &#60;summary&#62;<br />
///  This function give Post description field input, and check for fould word from Database. It also check against wildcard entry which is on database.<br />
/// &#60;/summary&#62;<br />
/// &#60;param name="textToCheck"&#62;Text to check with&#60;/param&#62;<br />
/// &#60;returns&#62;&#60;/returns&#62;<br />
private bool CheckForFoulWordInDescription(string textToCheck)<br />
{<br />
string _foulText= String.Empty;<br />
bool foulWordFound = false;<br />
DataSet ds = (DataSet)Cache["FoulWordDS"];<br />
DataTable dt = ds.Tables[0];<br />
foreach (DataRow dr in dt.Rows)<br />
{<br />
_foulText = dr["foulwords"].ToString();<br />
if (textToCheck.Contains(_foulText))<br />
{<br />
foulWordFound = true;<br />
break;<br />
}<br />
else if (_foulText.Contains("*") &#124;&#124;(_foulText.Contains("?")))<br />
{<br />
string rxString = WildcardToRegex(dr["foulwords"].ToString());<br />
// Instantiate the regular expression object.<br />
Regex r = new Regex(rxString, RegexOptions.IgnoreCase);<br />
string[] singleWord = textToCheck.Split(' ');<br />
// Match the regular expression pattern against a text string.<br />
foreach (string word in singleWord)<br />
{<br />
Match m = r.Match(word);<br />
if (m.Success)<br />
{<br />
foulWordFound = true;<br />
break;<br />
}<br />
}<br />
if (foulWordFound) break;<br />
}<br />
}<br />
return foulWordFound;}</p>
<p></code><br />
<br />
<code><br />
/// &#60;summary&#62;<br />
///  This function generate Regeguler expression for wildcard entry<br />
/// &#60;/summary&#62;<br />
/// &#60;param name="pattern"&#62;take wildcard string&#60;/param&#62;<br />
/// &#60;returns&#62;Regex string of wildcard string &#60;/returns&#62;<br />
public static string WildcardToRegex(string pattern)<br />
{<br />
return "^" + Regex.Escape(pattern).<br />
Replace("\\*", ".*").<br />
Replace("\\?", ".") + "$";<br />
}<br />
</code></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[How to dynamically create image thumbnails using CSS clip property with PHP glob() function]]></title>
<link>http://designtopx.wordpress.com/2009/11/18/how-to-dynamically-create-image-thumbnails-using-css-clip-property-with-php-glob-function/</link>
<pubDate>Wed, 18 Nov 2009 20:01:53 +0000</pubDate>
<dc:creator>Kalim Fleet</dc:creator>
<guid>http://designtopx.wordpress.com/2009/11/18/how-to-dynamically-create-image-thumbnails-using-css-clip-property-with-php-glob-function/</guid>
<description><![CDATA[&nbsp; In this tutorial, I will share with you an example of how you can use PHP to dynamically crea]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><hr /><a href="http://designtopx.wordpress.com/files/2009/11/title_appswebsite.png"><img class="alignnone size-full wp-image-99" title="title_appswebsite" src="http://designtopx.wordpress.com/files/2009/11/title_appswebsite.png" alt="blog post image" width="365" height="242" /></a></p>
<p>&#160;</p>
<p>In this tutorial, I will share with you an example of how you can use PHP to dynamically create and display images in a folder, all with very few lines of code, by utilizing PHP&#8217;s <strong><a href="http://us3.php.net/manual/en/function.glob.php">glob()</a></strong> function and the CSS <strong><a href="http://www.w3schools.com/CSS/pr_pos_clip.asp">clip</a></strong> property.<!--more--></p>
<p>View live demo here: <a href="http://bit.ly/4rNJWJ">Link</a></p>
<p><strong>Step 1:</strong><br />
Make sure your images are saved in a separate folder. I recommend you call the folder images</p>
<p><strong>Step 2:</strong><br />
Place all the images you will want to access for your website into the images folder. Make sure that this folder contains only the images you want to include on your webpage and no other images or file types.</p>
<p><strong>Step 3:</strong><br />
Rename all the images in the folder so that the first part of each image is exactly the same. e.g. <em>article001</em>_fooimage.png, <em>article001</em>_barimage.jpg, etc.  Since you are going to call for these later i would suggest you name the images in a way that you will easily remember (like sequentially based on when they are needed in a top 10 style post)</p>
<p><strong>Step 4:</strong><br />
Here is the php script that you can add to any page that will need to access the images.  If you prefer, you can save this php script as a separate file then use php include() to bring it in</p>
<div class="php" style="font-family:monospace;color:#006;border:1px solid #d0d0d0;background-color:#f0f0f0;">
<ol>
<li style="font-weight:normal;vertical-align:top;font:normal normal 130% 'Courier New', Courier, monospace;color:#003030;">
<div style="font:normal normal 1em/1.2em monospace;background:none;vertical-align:top;color:#000020;margin:0;padding:0;"><span style="color:#000000;font-weight:bold;">&#60;?php</span></div>
</li>
<li style="font-weight:normal;vertical-align:top;font:normal normal 130% 'Courier New', Courier, monospace;color:#003030;">
<div style="font:normal normal 1em/1.2em monospace;background:none;vertical-align:top;color:#000020;margin:0;padding:0;"><span style="color:#000088;">$filename</span> <span style="color:#339933;">=</span> <a style="color:#000060;" href="http://www.php.net/glob"><span style="color:#990000;">glob</span></a><span style="color:#009900;">(</span><span style="color:#0000ff;">&#8216;images/*.*&#8217;</span><span style="color:#009900;">)</span><span style="color:#339933;">;</span></div>
</li>
<li style="font-weight:normal;vertical-align:top;font:normal normal 130% 'Courier New', Courier, monospace;color:#003030;">
<div style="font:normal normal 1em/1.2em monospace;background:none;vertical-align:top;color:#000020;margin:0;padding:0;"><span style="color:#000000;font-weight:bold;">function</span> imagizer<span style="color:#009900;">(</span><span style="color:#000088;">$filename</span><span style="color:#009900;">)</span></div>
</li>
<li style="font-weight:normal;vertical-align:top;font:normal normal 130% 'Courier New', Courier, monospace;color:#003030;">
<div style="font:normal normal 1em/1.2em monospace;background:none;vertical-align:top;color:#000020;margin:0;padding:0;"><span style="color:#009900;">{</span></div>
</li>
<li style="font-weight:bold;vertical-align:top;color:#006060;">
<div style="font:normal normal 1em/1.2em monospace;background:none;vertical-align:top;color:#000020;margin:0;padding:0;"><span style="color:#b1b100;">return</span> <span style="color:#0000ff;">&#8220;&#60;div style=&#8217;position:relative; height:265px;&#8217;&#62;&#60;div style=&#8217;position:absolute; clip:rect(0px 256px 256px 0px);&#8217;&#62;&#60;img src=&#8217;<span style="color:#006699;font-weight:bold;">$filename</span>&#8216; alt=&#8217;image&#8217; /&#62;&#60;/div&#62;&#60;/div&#62;&#8221;</span><span style="color:#339933;">;</span></div>
</li>
<li style="font-weight:normal;vertical-align:top;font:normal normal 130% 'Courier New', Courier, monospace;color:#003030;"></li>
<li style="font-weight:normal;vertical-align:top;font:normal normal 130% 'Courier New', Courier, monospace;color:#003030;">
<div style="font:normal normal 1em/1.2em monospace;background:none;vertical-align:top;color:#000020;margin:0;padding:0;"><span style="color:#009900;">}</span></div>
</li>
<li style="font-weight:normal;vertical-align:top;font:normal normal 130% 'Courier New', Courier, monospace;color:#003030;"></li>
<li style="font-weight:normal;vertical-align:top;font:normal normal 130% 'Courier New', Courier, monospace;color:#003030;">
<div style="font:normal normal 1em/1.2em monospace;background:none;vertical-align:top;color:#000020;margin:0;padding:0;"><span style="color:#000088;">$images</span> <span style="color:#339933;">=</span> <a style="color:#000060;" href="http://www.php.net/array_map"><span style="color:#990000;">array_map</span></a><span style="color:#009900;">(</span><span style="color:#0000ff;">&#8220;imagizer&#8221;</span><span style="color:#339933;">,</span> <span style="color:#000088;">$filename</span><span style="color:#009900;">)</span><span style="color:#339933;">;</span></div>
</li>
<li style="font-weight:bold;vertical-align:top;color:#006060;">
<div style="font:normal normal 1em/1.2em monospace;background:none;vertical-align:top;color:#000020;margin:0;padding:0;"><span style="color:#000088;">$article001</span> <span style="color:#339933;">=</span> <a style="color:#000060;" href="http://www.php.net/array_values"><span style="color:#990000;">array_values</span></a><span style="color:#009900;">(</span><a style="color:#000060;" href="http://www.php.net/preg_grep"><span style="color:#990000;">preg_grep</span></a><span style="color:#009900;">(</span><span style="color:#0000ff;">&#8220;/article001/&#8221;</span><span style="color:#339933;">,</span> <span style="color:#000088;">$images</span><span style="color:#009900;">)</span><span style="color:#009900;">)</span><span style="color:#339933;">;</span></div>
</li>
<li style="font-weight:normal;vertical-align:top;font:normal normal 130% 'Courier New', Courier, monospace;color:#003030;"></li>
<li style="font-weight:normal;vertical-align:top;font:normal normal 130% 'Courier New', Courier, monospace;color:#003030;">
<div style="font:normal normal 1em/1.2em monospace;background:none;vertical-align:top;color:#000020;margin:0;padding:0;"><span style="color:#000000;font-weight:bold;">?&#62;</span></div>
</li>
</ol>
</div>
<p>The function imagizer will return an array of processed images based on your specifications.  I have chosen to do a 256&#215;256 pixel clip starting at the upper left hand corner of the image.  The entire image is still present though, it is only clipped to the visitors view.  If the visitor downloads the image, it will be the entire sized file and not the clip.  The first div that is created in the function is the container.  I made it 9 pixels taller than the clipped image container to add a little padding to the bottom of each generated image.</p>
<p>To call an image, simply use <strong>$article001[0]</strong> for the first image in the folder, <strong>$article001[1]</strong> for the second image, etc.</p>
<p>You can also do a for loop to print each image in a row.  This could be useful if you needed to add a bunch of images in a wysiwg html editor online and you didn&#8217;t have access to php.  You would just generate the code for all the images your the folder by running the php script like such:</p>
<div class="php" style="font-family:monospace;color:#006;border:1px solid #d0d0d0;background-color:#f0f0f0;">
<ol>
<li style="font-weight:normal;vertical-align:top;font:normal normal 130% 'Courier New', Courier, monospace;color:#003030;">
<div style="font:normal normal 1em/1.2em monospace;background:none;vertical-align:top;color:#000020;margin:0;padding:0;"><span style="color:#000000;font-weight:bold;">&#60;?php</span></div>
</li>
<li style="font-weight:normal;vertical-align:top;font:normal normal 130% 'Courier New', Courier, monospace;color:#003030;">
<div style="font:normal normal 1em/1.2em monospace;background:none;vertical-align:top;color:#000020;margin:0;padding:0;"><span style="color:#000088;">$max</span><span style="color:#339933;">=</span><a style="color:#000060;" href="http://www.php.net/count"><span style="color:#990000;">count</span></a><span style="color:#009900;">(</span><span style="color:#000088;">$article001</span><span style="color:#009900;">)</span><span style="color:#339933;">;</span></div>
</li>
<li style="font-weight:bold;vertical-align:top;color:#006060;">
<div style="font:normal normal 1em/1.2em monospace;background:none;vertical-align:top;color:#000020;margin:0;padding:0;"><span style="color:#b1b100;">for</span> <span style="color:#009900;">(</span><span style="color:#000088;">$i</span><span style="color:#339933;">=</span><span style="color:#cc66cc;">0</span><span style="color:#339933;">;</span><span style="color:#000088;">$i</span><span style="color:#339933;">&#60;</span><span style="color:#000088;">$max</span><span style="color:#339933;">;</span><span style="color:#000088;">$i</span><span style="color:#339933;">++</span><span style="color:#009900;">)</span></div>
</li>
<li style="font-weight:normal;vertical-align:top;font:normal normal 130% 'Courier New', Courier, monospace;color:#003030;">
<div style="font:normal normal 1em/1.2em monospace;background:none;vertical-align:top;color:#000020;margin:0;padding:0;"><span style="color:#009900;">{</span></div>
</li>
<li style="font-weight:normal;vertical-align:top;font:normal normal 130% 'Courier New', Courier, monospace;color:#003030;">
<div style="font:normal normal 1em/1.2em monospace;background:none;vertical-align:top;color:#000020;margin:0;padding:0;"><span style="color:#b1b100;">echo</span> <span style="color:#000088;">$article001</span><span style="color:#009900;">[</span><span style="color:#000088;">$i</span><span style="color:#009900;">]</span><span style="color:#339933;">;</span></div>
</li>
<li style="font-weight:normal;vertical-align:top;font:normal normal 130% 'Courier New', Courier, monospace;color:#003030;">
<div style="font:normal normal 1em/1.2em monospace;background:none;vertical-align:top;color:#000020;margin:0;padding:0;"><span style="color:#009900;">}</span></div>
</li>
<li style="font-weight:bold;vertical-align:top;color:#006060;">
<div style="font:normal normal 1em/1.2em monospace;background:none;vertical-align:top;color:#000020;margin:0;padding:0;"><span style="color:#000000;font-weight:bold;">?&#62;</span></div>
</li>
</ol>
</div>
<p>on your test environment, then go to the generated html page and copy and paste the html into your wysiwg editor.</p>
<p>Please feel free to leave any comments if you have any questions or suggestions about the code or use.</p>
<hr /><strong>About the Author</strong></p>
<p><strong> </strong><a href="http://kalimfleet.net">Kalim Fleet</a> is a professional web designer and blogger with over 6 years experience. The web is his passion as he splits his time between blog writing, software development and social media. He loves using and developing new applications for the web, mobile, and desktop.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Renaming files using Perl command rename]]></title>
<link>http://linuxindetails.wordpress.com/2009/11/16/renaming-files-using-perl-command-rename/</link>
<pubDate>Mon, 16 Nov 2009 12:19:02 +0000</pubDate>
<dc:creator>linuxindetails</dc:creator>
<guid>http://linuxindetails.wordpress.com/2009/11/16/renaming-files-using-perl-command-rename/</guid>
<description><![CDATA[I have been using this command for a while now and it helped very much.The command rename is availab]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I have been using this command for a while now and it helped very much.<br />The command <b>rename</b> is available in <b>perl package</b>. This is a core package brought by the Debian installer.<br />To check the availability of the command : <br /><b><br />fool@localhost:~$which rename<br />/usr/bin/rename</b></p>
<p>Having a closer look at the command, you will notice that it is a symbolic link to <b>/etc/alternatives/rename</b> :</p>
<p><b>fool@localhost:~$ls -l /usr/bin/rename<br />lrwxrwxrwx 1 root root 24 août&#160; 23&#160; 2008 /usr/bin/rename -&#62; /etc/alternatives/rename</b></p>
<p>To display the current configuration : <b></p>
<p>root@localhost:~#update-alternatives &#8211;display rename<br />rename &#8211; auto mode<br />&#160;link currently points to /usr/bin/prename<br />/usr/bin/prename &#8211; priority 60<br />&#160;slave rename.1.gz: /usr/share/man/man1/prename.1.gz<br />Current `best&#8217; version is /usr/bin/prename.</b></p>
<p>How to use this command?<br />Quite simple if you know how to use regular expressions.<br />Thanks to the option <b>-n</b>, you can test your regular expression without renaming your files effectively.<br />Let us have an example :</p>
<p><b>fool@localhost:~$touch fool_1.t fool_2.t</b></p>
<p>If you want to rename fool_1.t and fool_2.t into fool1.t and fool2.t :&#160; <br /><b>fool@localhost:~$rename -n &#8217;s/_//g&#8217; *.t<br />fool_1.t renamed as fool1.t<br />fool_2.t renamed as fool2.t</b></p>
<p>To rename the files permanently, remove the option &#8216;<b>-n</b>&#8216; : <br /><b>fool@localhost:~$rename &#8217;s/_//g&#8217; *.t</b></p>
<p>More information :<br /><b><br />man rename </b><br />&#160;</p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" alt="" src="http://img.zemanta.com/pixy.gif?x-id=7c9754ca-47f6-8a35-8892-55f6f8a3b260" /></div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[cú pháp regex]]></title>
<link>http://dyelvn.wordpress.com/2009/11/16/cu-phap-regex/</link>
<pubDate>Mon, 16 Nov 2009 02:22:02 +0000</pubDate>
<dc:creator>keithervn</dc:creator>
<guid>http://dyelvn.wordpress.com/2009/11/16/cu-phap-regex/</guid>
<description><![CDATA[. Mọi ký tự trừ ký tự xuống dòng. \d Ký tự chữ số thập phân (digit). \D Ký tự không phải chữ số (non]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>.   Mọi ký tự trừ ký tự xuống dòng.</p>
<p>\d   Ký tự chữ số thập phân (digit).</p>
<p>\D   Ký tự không phải chữ số (non-digit).</p>
<p>\s   Ký tự whitespace (như khoảng trắng, tab,..)</p>
<p>\S   Ký tự none-whitespace</p>
<p>\w  Ký tự word(gồm mẫu tự, chữ số và dấu gạch dưới).</p>
<p>\W   Ký tự none-word</p>
<p>^   Bắt đầu một chuỗi hoặc dòng</p>
<p>\A   Bắt đầu một chuỗi</p>
<p>$   Kết thúc một chuối hoặc dòng</p>
<p>\z   Kết thúc một chuối</p>
<p>&#160;</p>
<p>&#124;   Ngăn cách các biểu thức có thể so trùng, ví dụ AAA&#124;ABA&#124;ABB sẽ so trùng với AAA,ABA hoặc ABB. Các biểu thức được so trùng từ trái sáng</p>
<p>[abc]   So trùng với một trong các ký tự trong nhóm, ví dụ [Abc] sẽ so trùng với A, b, c</p>
<p>[^abc]   So trùng với bất cứ ký tự nào không thuộc các ký tự trong nhóm, ví dụ [^AbC] sẽ không so trùng cới A, b, C nhưng so trùng với B, F,…</p>
<p>[a-z]   So trùng với bất kỳ ký tự nào thuộc khoảng này, ví dụ [A-C] sẽ so trùng với A,B hoặc C</p>
<p>( )   Xác định một biểu thức con sao cho nó được xem nư 1 yếu tố đơn lẻ với các yếu tố được trình bày trong bảng này</p>
<p>?   Xác định có một hoặc không có ký tự hoặc biểu thức con đứng trước nó, ví dụ A?B so trùng với B,AB; nhưng không so trùng với AAB</p>
<p>*   Xác định không có hoặc có nhiều ký tự hoặc biểu thức con đứng trước nó, ví dụ A*B so trùng với B, AB,AAB,AAAB,…</p>
<p>+   Xác định có một hoặc có nhiều ký tự hoặc biểu thức con đứng trước nó, ví dụ A+B so trùng với AB, AAB, AAAB,… nhưng không so trùng với B.</p>
<p>{n}   Xác định có đúng n ký tự hoặc biểu thức con đứng trước nó, ví dụ A{2} chỉ so trùng với AA</p>
<p>{n,}   Xác định có ít nhất n ký tự hoặc biểu thức con đứng trước đó, ví dụ A{2,} so trùng với AA, AAA,AAAA,… nhưng không so trùng với A.</p>
<p>{n,m}   Xác định có từ n đến m ký tự đứng trước đó, ví dụ A{2,4} so trùng với AA,AAA, AAAA nhưng không so trùng với A hoặc AAAAA</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Regular Expressions in C#- Advanced Language Elements]]></title>
<link>http://spolnik.wordpress.com/2009/11/15/regular-expressions-in-c-advanced-language-elements/</link>
<pubDate>Sun, 15 Nov 2009 20:34:23 +0000</pubDate>
<dc:creator>Jacek Spólnik</dc:creator>
<guid>http://spolnik.wordpress.com/2009/11/15/regular-expressions-in-c-advanced-language-elements/</guid>
<description><![CDATA[Regular Expression Advanced Language Elements Grouping Constructs ( ) - captures the matched substri]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><h2>Regular Expression Advanced Language Elements</h2>
<h3>Grouping Constructs</h3>
<ul>
<li><strong>(   ) </strong>- captures the matched substring (or noncapturing group). Captures using () are numbered automatically based on the order of the opening parenthesis, starting from one. The first capture, capture element number zero, is the text matched by the whole regular expression pattern</li>
<li><strong>(?&#60;<em>name&#62;</em></strong><strong> )<strong> </strong></strong>- captures the matched substring into a group name or number name. The string used for name must not contain any punctuation and it cannot begin with a number. You can use single quotes instead of angle brackets</li>
<li><strong>(?&#60;<em>name1-name2</em>&#62;</strong><strong> )<strong><strong> </strong></strong></strong>- balancing group definition. Deletes the definition of the previously defined group name2 and stores in group name1 the interval between the previously defined name2 group and the current group. If no group name2 is defined, the match backtracks. Because deleting the last definition of name2 reveals the previous definition of name2, this construct allows the stack of captures for group name2 to be used as a counter for keeping track of nested constructs such as parentheses. In this construct, name1 is optional. You can use single quotes instead of angle brackets</li>
<li><strong>(?:   )</strong> &#8211; noncapturing group</li>
<li><strong>(?imnsx-imnsx:   )</strong> &#8211; applies or disables the specified options within the subexpression. For example, (?i-s: ) turns on case insensitivity and disables single-line mode</li>
<li><strong>(?=   )</strong> &#8211; zero-width positive lookahead assertion. Continues match only if the subexpression matches at this position on the right. For example, \w+(?=\d) matches a word followed by a digit, without matching the digit. This construct does not backtrack</li>
<li><strong>(?!   )</strong> &#8211; zero-width negative lookahead assertion. Continues match only if the subexpression does not match at this position on the right. For example, \b(?!un)\w+\b matches words that do not begin with un</li>
<li><strong>(?&#60;=   )</strong><strong><strong> </strong></strong>-zero-width positive lookbehind assertion. Continues match only if the subexpression matches at this position on the left. For example, (?&#60;=19)99 matches instances of 99 that follow 19. This construct does not backtrack</li>
<li><strong>(?&#60;!&#8211;   )</strong> &#8211; zero-width negative lookbehind assertion. Continues match only if the subexpression does not match at the position on the left</li>
<li><strong>(?&#62;   )</strong> &#8211; nonbacktracking subexpression (also known as a &#8220;greedy&#8221; subexpression). The subexpression is fully matched once, and then does not participate piecemeal in backtracking (That is, the subexpression matches only strings that would be matched by the subexpression alone.)</li>
<p><em>Named captures are numbered sequentially, based on the left-to-right order of the opening parenthesis (like unnamed captures), but numbering of named captures starts after all unnamed captures have been counted.<br />
</em></ul>
<h3>Backreference Constructs</h3>
<ul>
<li><strong>\number</strong> &#8211; backreference. For example, (\w)\1 finds doubled word characters</li>
<li><strong>\k &#60;<em>name</em>&#62; </strong>- named backreference. For example, (?\w)\k finds doubled word characters. The expression (?&#60;43&#62;\w)\43 does the same. You can use single quotes instead of angle brackets; for example, \k&#8217;char&#8217;</li>
</ul>
<h3>Alternation Constructs</h3>
<ul>
<li><strong>&#124;</strong> &#8211; matches any one of the terms separated by the &#124; (vertical bar) character. The leftmost successful match wins</li>
<li><strong>(?(expression)yes&#124;no)  &#8211; </strong>matches the &#8220;yes&#8221; part if the expression matches at this point; otherwise, matches the &#8220;no&#8221; part. The &#8220;no&#8221; part can be omitted. The expression can be any valid subexpression, but it is turned into a zero-width assertion, so this syntax is equivalent to (?(?=expression)yes&#124;no). Note that if the expression is the name of a named group or a capturing group number, the alternation construct is interpreted as a capture test (described in the next row of this table). To avoid confusion in these cases, you can spell out the inside (?=expression) explicitly</li>
<li><strong>(?(name)yes&#124;no)</strong> &#8211; matches the &#8220;yes&#8221; part if the named capture string has a match; otherwise, matches the &#8220;no&#8221; part. The &#8220;no&#8221; part can be omitted. If the given name does not correspond to the name or number of a capturing group used in this expression, the alternation construct is interpreted as an expression test (described in the preceding row of this table)</li>
</ul>
<h3>Miscellaneous Constructs</h3>
<ul>
<li><strong>(?imnsx-imnsx)</strong> &#8211; sets or disables options such as case insensitivity to be turned on or off in the middle of a pattern. Option changes are effective until the end of the enclosing group. See also the information on the grouping construct (?imnsx-imnsx: ), which is a cleaner form</li>
<li><strong>(?# )</strong> &#8211; inline comment inserted within a regular expression. The comment terminates at the first closing parenthesis character</li>
<li><strong># [to end of line]</strong> &#8211; X-mode comment. The comment begins at an unescaped # and continues to the end of the line. (Note that the x option or the RegexOptions.IgnorePatternWhitespace enumerated option must be activated for this kind of comment to be recognized.)</li>
</ul>
<h2>Bibliography</h2>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/az24scfc%28VS.71%29.aspx" target="_blank">MSDN</a></li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Roundup: The Best Web Design Cheat Sheets]]></title>
<link>http://designtopx.wordpress.com/2009/11/13/roundup-the-best-web-design-cheat-sheets/</link>
<pubDate>Fri, 13 Nov 2009 22:10:42 +0000</pubDate>
<dc:creator>Kalim Fleet</dc:creator>
<guid>http://designtopx.wordpress.com/2009/11/13/roundup-the-best-web-design-cheat-sheets/</guid>
<description><![CDATA[Web designers often have to wear many hats.  They must aptly switch from being a developer, coder, a]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Web designers often have to wear many hats.  They must aptly switch from being a developer, coder, administrator and designer at a clients request.  There is simply too much information to know all at once so I have provided the best<!--more--> cheat sheets I have found for the various technology that you will come across in your projects.  A number of elements are covered including PHP, regex, wordpress, css, fonts,  gimp, html, javascript, jQuery, mod rewrite, mysql, photoshop, and more.  <strong>Note: All cheat sheets are in .PDF format.</strong></p>
<p><strong> </strong></p>
<p><strong> </strong> <a href="http://www.box.net/shared/7x2dudmylf">Download all cheetsheets in one zip file here</a></p>
<p><strong>1.  PHP</strong></p>
<ul>
<li><a href="http://designtopx.wordpress.com/files/2009/11/0php_reference_sheet.pdf">php_reference_sheet</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/0php-cheat-sheet-v1.pdf">php-cheat-sheet-v1</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/0php-5-online-cheat-sheet-v1-3.pdf">PHP 5 Online Cheat Sheet v1.3</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/php-cheat-sheet-v2.pdf">php-cheat-sheet-v2</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/phprefcard.pdf">PHPRefCard</a></li>
</ul>
<p><strong>2. CSS</strong></p>
<ul>
<li><a href="http://designtopx.wordpress.com/files/2009/11/cssquick.pdf">cssquick</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/csscheatsheet.pdf">csscheatsheet</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/0css-cheat-sheet.pdf">css-cheat-sheet</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/cssqrg0007.pdf">CSSqrg0007</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/css_cheatsheet_v2.pdf">css_cheatsheet_v2</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/css3-cheat-sheet.pdf">css3-cheat-sheet</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/0csscheatsheet.pdf">csscheatsheet</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/zcss2qrg0007.pdf">CSS2qrg0007</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/0blueprintv0-8bygjms.pdf">BlueprintV0.8byGJMS</a></li>
</ul>
<p><strong>3.  WordPress</strong></p>
<ul>
<li><a href="http://designtopx.wordpress.com/files/2009/11/wphelpsheet.pdf">WPHelpSheet</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/wp_theme_tags.pdf">WP_Theme_Tags</a></li>
<li> <a href="http://designtopx.wordpress.com/files/2009/11/wp_loop.pdf">WP_loop</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/wordpress-theme-development-check-list.pdf">wordpress-theme-development-check-list</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/wordpress_cheatsheet_v1.pdf">WordPress_Cheatsheet_v1</a></li>
</ul>
<p><strong>4.  Image Editing</strong></p>
<ul>
<li><a href="http://designtopx.wordpress.com/files/2009/11/gimp-saclug.pdf">gimp-saclug</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/photoshop.pdf">Photoshop</a></li>
</ul>
<p><strong>5. Color, Typography</strong></p>
<ul>
<li><a href="http://designtopx.wordpress.com/files/2009/11/rgb-hex-cheat-sheet-v1.pdf">rgb-hex-cheat-sheet-v1</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/0common-fonts-to-all-versions-of-windows-mac-equivalents.pdf">Common fonts to all versions of Windows &#38; Mac equivalents</a></li>
</ul>
<p><strong>6. Javascript</strong></p>
<ul>
<li><a href="http://designtopx.wordpress.com/files/2009/11/javascriptquick.pdf">javascriptquick</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/javascript-cheat-sheet-v1.pdf">javascript-cheat-sheet-v1</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/zjavascriptcheatsheet.pdf">javascriptcheatsheet</a></li>
</ul>
<p><strong>7.  jQuery</strong></p>
<ul>
<li><a href="http://designtopx.wordpress.com/files/2009/11/jquery-cheat-sheet-1-2.pdf">Jquery-Cheat-Sheet-1.2</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/jquerycheatsheet-1-3-2.pdf">JQueryCheatSheet-1.3.2</a></li>
<li> <a href="http://designtopx.wordpress.com/files/2009/11/jquery_1-3_cheatsheet_v1.pdf">jquery_1.3_cheatsheet_v1</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/jquery1-2-cheatsheet-v1-0.pdf">jQuery1.2.cheatsheet.v1.0</a></li>
</ul>
<p><strong>8. HTML</strong></p>
<ul>
<li><a href="http://designtopx.wordpress.com/files/2009/11/html-cheat-sheet-v1.pdf">html-cheat-sheet-v1</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/html-help-sheet-02.pdf">HTML Help Sheet 02</a></li>
<li> <a href="http://designtopx.wordpress.com/files/2009/11/html-character-entities-cheat-sheet.pdf">html-character-entities-cheat-sheet</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/zhtmlcheatsheet.pdf">htmlcheatsheet</a></li>
</ul>
<p><strong>9. Web Administration</strong></p>
<ul>
<li><a href="http://designtopx.wordpress.com/files/2009/11/unix_cheat_sheet.pdf">Unix_cheat_sheet</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/unix_cheatsheet.pdf">Unix_cheatsheet</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/svn-refcard.pdf">svn-refcard</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/mod_rewrite-cheat-sheet-v2.pdf">mod_rewrite-cheat-sheet-v2</a></li>
</ul>
<p><strong>10.  Regex</strong></p>
<ul>
<li><a href="http://designtopx.wordpress.com/files/2009/11/regex-regular-expressions-cheat-sheet-v2.pdf">regex-regular-expressions-cheat-sheet-v2</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/regex-8-regular-expressions-you-should-know.pdf">regex 8 Regular Expressions You Should Know</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/regex-10-practical-php-regular-expression-recipes.pdf">regex-10 Practical PHP Regular Expression Recipes</a></li>
<li> <a href="http://designtopx.wordpress.com/files/2009/11/list_of_grep_symbols.pdf">list_of_grep_symbols</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/0_php-pcre-cheat-sheet.pdf">PHP PCRE Cheat Sheet</a></li>
</ul>
<p><strong>11. SQL</strong></p>
<ul>
<li><a href="http://designtopx.wordpress.com/files/2009/11/sqlcheatcheet.pdf">sqlcheatcheet</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/zmysql_cheatsheet.pdf">mySQL_Cheatsheet</a></li>
</ul>
<p><strong>12.  Bonus</strong></p>
<ul>
<li> <a href="http://designtopx.wordpress.com/files/2009/11/xml-schema-structures.pdf">XML Schema &#8211; Structures</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/zxmlquickref.pdf">XMLquickref</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/zrss_cheatsheet.pdf">rss_cheatsheet</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/zfilteringandescapingcheatsheet.pdf">filteringandescapingcheatsheet</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/seo_web_developer_cheat_sheet.pdf">SEO_Web_Developer_Cheat_Sheet</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/cheat-sheet-seo-for-wordpress.pdf">cheat-sheet-seo-for-wordpress</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/blogger_cheatsheet_v1.pdf">Blogger_Cheatsheet_v1</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/movable_type_cheatsheet_v1.pdf">Movable_Type_Cheatsheet_v1</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/microformats-cheat-sheet-v1.pdf">microformats-cheat-sheet-v1</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/microformats-cheatsheet.pdf">microformats.cheatsheet</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/python-cheat-sheet-v1.pdf">python-cheat-sheet-v1</a></li>
<li><a href="http://designtopx.wordpress.com/files/2009/11/as3_adv_cheat_sheet_02.pdf">AS3_Adv_Cheat_Sheet_02</a></li>
</ul>
<hr /><strong>About the Author</strong></p>
<p>&#160;</p>
<p><strong> </strong><a href="http://kalimfleet.net">Kalim Fleet</a> is a professional web designer and blogger with over 6 years experience. The web is his passion as he splits his time between blog writing, software development and social media. He loves using and developing new applications for the web, mobile, and desktop.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[That Regex thing]]></title>
<link>http://myvisualthoughts.wordpress.com/2009/11/13/that-regex-thing/</link>
<pubDate>Fri, 13 Nov 2009 16:01:00 +0000</pubDate>
<dc:creator>G.</dc:creator>
<guid>http://myvisualthoughts.wordpress.com/2009/11/13/that-regex-thing/</guid>
<description><![CDATA[Here is one of the most simple applications I could have ever thought of&#8230; yet I didn&#8217;t! ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Here is one of the most simple applications I could have ever thought of&#8230; yet I didn&#8217;t! Recently, a colleague of mine, Leandro Fernandez, pointed out the good fact that most of the time, developers that are involved in any kind of parsing task rely on regular expressions to do so. Only when they are done, not much else regular expression related work is left to be done. Such a scenario results in coming back to the same query in Google: &#8220;online regex generator&#8221;.</p>
<p>So far, so good! Nothing new, nothing fancy. Although, knowing that I am kind of an &#8221;infovis enthusiast&#8221;, my kind friend suggested I created a visual tool for such an event, making it fairly simple and easy to create regular expressions using bubbles, colors and interaction.</p>
<p>Such is the tale of the birth of the new tool I&#8217;m starting to work in: That Regex Thing. Soon in a webpage close to you.</p>
<p>&#160;</p>
<p>That&#8217;s it, that&#8217;s all!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Form submission: clean up formatted contact e-mail]]></title>
<link>http://rickyrobinett.wordpress.com/2009/11/13/form-submission-clean-up-formatted-contact-e-mail/</link>
<pubDate>Fri, 13 Nov 2009 14:00:29 +0000</pubDate>
<dc:creator>rickyrobinett</dc:creator>
<guid>http://rickyrobinett.wordpress.com/2009/11/13/form-submission-clean-up-formatted-contact-e-mail/</guid>
<description><![CDATA[Frequently, when creating a form that accepts e-mail addresses I see a lot of bad data that comes in]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Frequently, when creating a form that accepts e-mail addresses I see a lot of bad data that comes in as a result of the user copying a contact out of the e-mail client (Outlook, Firebird, etc.). I decided it would be helpful to write a basic script that cleans up the most common occurances of this issue.</p>
<p>The 3 common occurances I saw of this issue where:<br />
FName LName (email)<br />
FName LName [email]<br />
FName LName &#60;email&#62;</p>
<p>The code I used to clean up these was:</p>
<pre>&#60;input type="text" value="" style="width:300px;" onchange="this.value=this.value.replace(/[^\(\&#60;\[)]*[\(\[\&#60;](?=.)/gi,'').replace(/[\)\&#62;\]]/gi,'')" /&#62;
&#60;input type="text" value="Something to tab to"/&#62;
</pre>
<p>Obviously you&#8217;d want to move this into a function, but I just wanted a quick and dirty example. I call two regular expressions to clean this up since JavaScript doesn&#8217;t allow for look-arounds. I hope these expressions can help others who may be experiencing the same problem.</p>
<p>&#160;</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[PHP Form Validation functions]]></title>
<link>http://scvinodkumar.wordpress.com/2009/11/06/php-form-validation-functions/</link>
<pubDate>Fri, 06 Nov 2009 12:04:51 +0000</pubDate>
<dc:creator>Chandra Sekar Vinod Kumar</dc:creator>
<guid>http://scvinodkumar.wordpress.com/2009/11/06/php-form-validation-functions/</guid>
<description><![CDATA[Recently i have involve myself in another application development. Regular Hungred Dot Com visitors ]]></description>
<content:encoded><![CDATA[Recently i have involve myself in another application development. Regular Hungred Dot Com visitors ]]></content:encoded>
</item>
<item>
<title><![CDATA[Regular Expression Date Validation]]></title>
<link>http://oninit.wordpress.com/2009/11/05/regular-expression-date-validation/</link>
<pubDate>Thu, 05 Nov 2009 17:07:53 +0000</pubDate>
<dc:creator>Virgil</dc:creator>
<guid>http://oninit.wordpress.com/2009/11/05/regular-expression-date-validation/</guid>
<description><![CDATA[MM/DD/YY (0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.]\d\d]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><table cellspacing="2" cellpadding="8">
<tbody>
<tr>
<td>MM/DD/YY</td>
<td><strong><code>(0[1-9]&#124;1[012])[- /.](0[1-9]&#124;[12][0-9]&#124;3[01])[- /.]\d\d</code></strong></td>
</tr>
</tbody>
</table>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[emacs strip blank lines]]></title>
<link>http://edivad.wordpress.com/2009/11/02/emacs-strip-blank-lines/</link>
<pubDate>Sun, 01 Nov 2009 22:00:16 +0000</pubDate>
<dc:creator>edivad</dc:creator>
<guid>http://edivad.wordpress.com/2009/11/02/emacs-strip-blank-lines/</guid>
<description><![CDATA[Spiral-Bound Pad (by incurable_hippie) Here is a quick way to strip (remove) blank lines from a file]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p style="text-align:center;">
<div class="wp-caption aligncenter" style="width: 250px"><a href="http://www.flickr.com/photos/hippie/2475849569/"><img title="Spiral-Bound Pad" src="http://farm4.static.flickr.com/3080/2475849569_514e542c25_m_d.jpg" alt="Spiral-Bound Pad" width="240" height="161" /></a><p class="wp-caption-text">Spiral-Bound Pad (by incurable_hippie)</p></div>
<p>Here is a quick way to strip (remove) blank lines from a file with emacs.</p>
<ol>
<li>position on top of file: <em>M-&#60;</em></li>
<li>Call a query-regex-replace: <em>M-C-%</em></li>
<li>input the regex <em>^ C-q C-j</em> that stand for match all lines that consist in only a carriage return.</li>
<li><em>RET-RET</em>. The first one confirm the regex and the last one is for &#8220;replace with nothing&#8221;.</li>
<li>When asked use <em>!</em> to replace-all.</li>
</ol>
<p>Summing all commands:</p>
<p style="text-align:center;"><strong>M-&#60; C-M-% ^ C-q C-j RET RET !</strong></p>
<p>here you are <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[利用Regex檢查是否為數值(ASP.NET)]]></title>
<link>http://kuanglian2000.wordpress.com/2009/10/27/%e5%88%a9%e7%94%a8regex%e6%aa%a2%e6%9f%a5%e6%98%af%e5%90%a6%e7%82%ba%e6%95%b8%e5%80%bcasp-net/</link>
<pubDate>Tue, 27 Oct 2009 08:03:48 +0000</pubDate>
<dc:creator>kuanglian2000</dc:creator>
<guid>http://kuanglian2000.wordpress.com/2009/10/27/%e5%88%a9%e7%94%a8regex%e6%aa%a2%e6%9f%a5%e6%98%af%e5%90%a6%e7%82%ba%e6%95%b8%e5%80%bcasp-net/</guid>
<description><![CDATA[public bool CheckIsNumber(string val) { Regex reNum = new Regex(@&#8221;^\d+$&#8221;); bool isNumeri]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>public bool CheckIsNumber(string val)<br />
{<br />
Regex reNum = new Regex(@&#8221;^\d+$&#8221;);<br />
bool isNumeric = reNum.Match(val).Success;<br />
return isNumeric;<br />
}</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Regular Expression to Match a DOI (Digital Object Identifier)]]></title>
<link>http://doeidoei.wordpress.com/2009/10/22/regular-expression-to-match-a-doi-digital-object-identifier/</link>
<pubDate>Thu, 22 Oct 2009 06:05:32 +0000</pubDate>
<dc:creator>João</dc:creator>
<guid>http://doeidoei.wordpress.com/2009/10/22/regular-expression-to-match-a-doi-digital-object-identifier/</guid>
<description><![CDATA[The DOI (Digital Object Identifier) is an unique identifier used in biomedical publications (and in ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p style="text-align:justify;">The DOI (Digital Object Identifier) is an unique identifier used in biomedical publications (and in many other places). Due to lazy scientists, or lazy editors, not tagging the PDF correctly, it&#8217;s the only information that I could find parsable from any research paper. I wrote the regular expression to be used in Python. It retrieves the DOI in the format 10.1234.whateverishere. It finishes searching when it finds a space or a capital letter, which is usually the case. I tested it on 40 papers from several journals and it retrieved the doi perfectly from 39.</p>
<pre><strong><span style="color:#000000;">regexDOI = re.compile('[doi&#124;DOI][\s\.\:]{0,2}(10\.\d{4}[\d\:\.\-\/a-z]+)[A-Z\s]')</span></strong></pre>
<p style="text-align:justify;">
<p style="text-align:justify;">I&#8217;m open to suggestions to improve the regex and to test it against more papers. Feel free <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p style="text-align:justify;">
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Regular expressions - preg_replace()]]></title>
<link>http://web4us.wordpress.com/2009/10/21/regular-expressions-preg_replace/</link>
<pubDate>Wed, 21 Oct 2009 12:32:53 +0000</pubDate>
<dc:creator>webforus</dc:creator>
<guid>http://web4us.wordpress.com/2009/10/21/regular-expressions-preg_replace/</guid>
<description><![CDATA[The preg_replace function is used to do a find-and-replace on a string or an array. We can give it o]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>The <em>preg_replace</em> function is used to do a find-and-replace on a string or an array. We can give it one thing to find and replace (for example it seeks out the word &#8216;him&#8217; and changes it to &#8216;her&#8217;) or we can give it a full list of things (an array) to search for, each with a corresponding replacement. It is phrased as <strong>preg_replace ( search_for, replace_with, your_data , optional_limit, optional_count )</strong> The limit will default to -1 which is no limit.  Remember your_data can be a string or an array.<br />
<!--more--></p>
<pre>
&#60;?php
$data = "The cat likes to sit on the fence. He also likes to climb the tree.";

$find ="/the/";
$replace ="a";

//1. replace single word
Echo "$data ";
Echo preg_replace ($find, $replace, $data);

//create arrays
$find2 = array ('/the/', '/cat/');
$replace2 = array ('a', 'dog');

//2. replace with array values
Echo preg_replace ($find2, $replace2, $data);

//3. Replace just once
Echo preg_replace ($find2, $replace2, $data, 1);

//4. Keep a count of replacements
$count = 0;
Echo preg_replace ($find2, $replace2, $data, -1, $count);
Echo "You have made $count replacements";

?&#62;
</pre>
<p>In our first example we simply replace &#8216;the&#8217; with &#8216;a&#8217;. As you can see these are cAse seNsiTIvE. Then we set up an array, so in our second example we are replacing both the words &#8216;the&#8217; and &#8216;cat&#8217;. In our third example, we set the limit to 1, so each word is only replaced one time. Finally in our 4th example, we keep count of how many replacements we have made. </p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Regular expressions - preg_match_all()]]></title>
<link>http://web4us.wordpress.com/2009/10/21/regular-expressions-preg_match_all/</link>
<pubDate>Wed, 21 Oct 2009 12:23:33 +0000</pubDate>
<dc:creator>webforus</dc:creator>
<guid>http://web4us.wordpress.com/2009/10/21/regular-expressions-preg_match_all/</guid>
<description><![CDATA[Preg_Match_All is used to search a string for specific patterns and stores the results in an array. ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><em>Preg_Match_All</em> is used to search a string for specific patterns and stores the results in an array.  Unlike <em>preg_match</em> which stops searching after it finds a match, <em>preg_match_all</em> searches the entire string and records all matches.  It is phrased as: <strong>preg_match_all (pattern, string, $array, optional_ordering, optional_offset)</strong></p>
<p><!--more--></p>
<pre>&#60;?php
 $data = "The party will start at 10:30 pm and run untill 12:30 am";
 <strong>preg_match_all</strong>('/(\d+:\d+)\s*(am&#124;pm)/', $data, $match, <em>PREG_PATTERN_ORDER</em>);
 print_r($match);
 ?&#62;
<strong>Output</strong>
Array
(
    [0] =&#62; Array
        (
            [0] =&#62; 10:30 pm
            [1] =&#62; 12:30 am
        )

    [1] =&#62; Array
        (
            [0] =&#62; 10:30
            [1] =&#62; 12:30
        )

    [2] =&#62; Array
        (
            [0] =&#62; pm
            [1] =&#62; am
        )

)
</pre>
<p>In our first example we use PREG_PATTERN_ORDER. We are searching for 2 things; one is the time, the other is it&#8217;s am/pm tag. Our results are outputted to $match, as an array where $match[0] contains all matches, $match[1] contains all data matching our first sub-serach (the time) and $match[2] contains all data matching our second sub-search (am/pm).</p>
<pre>&#60;?php
 $data = "The party will start at 10:30 pm and run untill 12:30 am";
 <strong>preg_match_all</strong>('/(\d+:\d+)\s*(am&#124;pm)/', $data, $match, <em>PREG_SET_ORDER</em>);
print_r($match);
 ?&#62;
<strong>Output</strong>
Array
(
    [0] =&#62; Array
        (
            [0] =&#62; 10:30 pm
            [1] =&#62; 10:30
            [2] =&#62; pm
        )

    [1] =&#62; Array
        (
            [0] =&#62; 12:30 am
            [1] =&#62; 12:30
            [2] =&#62; am
        )

)

(
    [0] =&#62; Array
        (
            [0] =&#62; 10:30 pm
            [1] =&#62; 10:30
            [2] =&#62; pm
        )

    [1] =&#62; Array
        (
            [0] =&#62; 12:30 am
            [1] =&#62; 12:30
            [2] =&#62; am
        )

)
</pre>
<p>In our second example we use PREG_SET_ORDER. This puts each full result into an array. The first result is $match[0], with $match[0][0] being the full match, $match[0][1] being the first sub-match and $match[0][2] being the second sub-match. </p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Regular expressions - preg_grep()]]></title>
<link>http://web4us.wordpress.com/2009/10/21/regular-expressions-preg_grep/</link>
<pubDate>Wed, 21 Oct 2009 11:45:07 +0000</pubDate>
<dc:creator>webforus</dc:creator>
<guid>http://web4us.wordpress.com/2009/10/21/regular-expressions-preg_grep/</guid>
<description><![CDATA[The PHP function, preg_grep, is used to search an array for specific patterns and then return a new ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>The PHP function, <em>preg_grep</em>, is used to search an array for specific patterns and then return a new array based on that filtering. There are two ways to return the results. You can return them as is, or you can invert them (instead of only returning what matches, it would only return what does not match.) It is phrased as: <strong>preg_grep ( search_pattern, $your_array, optional_inverse )</strong> The search_pattern needs to be a regular expression.  If you are unfamiliar with them this article gives you an overview of the syntax.</p>
<pre>&#60;?php
$data = array(0, 1, 2, 'three', 4, 5, 'six', 7, 8, 'nine', 10);
$mod1 = <strong>preg_grep</strong>("/4&#124;5&#124;6/", $data);
$mod2 = <strong>preg_grep</strong>("/[0-9]/", $data, PREG_GREP_INVERT);
print_r($mod1);
echo "&#60;br&#62;";
print_r($mod2);
?&#62;
</pre>
<p>This code would result in the following data:<br />
Array ( [4] =&#62; 4 [5] =&#62; 5 )<br />
Array ( [3] =&#62; three [6] =&#62; six [9] =&#62; nine )</p>
<p>First we assign our $data variable. This is a list of numbers, some in alpha form, others in numeric. The first thing we run is called $mod1. Here we are searching for anything that contains 4, 5, or 6. When our result is printed below we only get 4 and 5, because 6 was written as &#8217;six&#8217; so it did not match our search.</p>
<p>Next we run $mod2, which is searching for anything that contains a numeric character. But this time we include PREG_GREP_INVERT. This will invert our data, so instead of outputting numbers, it outputs all of our entries that where not numeric (three, six and nine).</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Regular expressions - preg_match()]]></title>
<link>http://web4us.wordpress.com/2009/10/21/regular-expressions/</link>
<pubDate>Wed, 21 Oct 2009 11:06:58 +0000</pubDate>
<dc:creator>webforus</dc:creator>
<guid>http://web4us.wordpress.com/2009/10/21/regular-expressions/</guid>
<description><![CDATA[PHP regular expressions seems to be a quite complicated area especially if you are not an experience]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>PHP regular expressions seems to be a quite complicated area especially if you are not an experienced Unix user. Historically regular expressions were originally designed to help working with strings under Unix systems.</p>
<p>Using regular expressions you can easy find a pattern in a string and/or replace it if you want. This is a very powerful tool in your hand, but be careful as it is slower than the standard string manipulation functions.<br />
<!--more--><br />
<strong>Regular expression types</strong></p>
<p>There are 2 types of  regular expressions:</p>
<ul>
<li>POSIX Extended</li>
<li>Perl Compatible</li>
</ul>
<p>The ereg, eregi, &#8230; are the POSIX versions and preg_match, preg_replace, &#8230; are the Perl version. It is important that using Perl compatible regular expressions the expression should be enclosed in the delimiters, a forward slash (/), for example. However this version is more powerful and faster as well than the POSIX one.</p>
<p><strong>The regular expressions basic syntax</strong></p>
<p>To use regular expressions first you need to learn the syntax of the patterns. We can group the characters inside a pattern like this:</p>
<ul>
<li>Normal characters which match themselves like hello</li>
<li>Start and end indicators as ^ and $</li>
<li>Count indicators like +,*,?</li>
<li>Logical operator like &#124;</li>
<li>Grouping with {},(),[]</li>
</ul>
<p>An example pattern to check valid emails looks like this:</p>
<div>
<div>Code:</div>
<p>^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$</pre>
</div>
<p>The code to check the email using Perl compatible regular expression looks like this:</p>
<pre>
&#60;?php
$pattern = "/^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$/";
$str = "test@test.com";
if(preg_match($pattern,$str))
	echo "match";
else
	echo "not match";
?&#62;
</pre>
<p>Here is syntax pattern</p>
<table cellspacing="1" cellpadding="5" border="0" bgcolor="#f0f0f0" width="900">
<tbody>
<tr>
<th>
<p>Regular expression (pattern)</p>
</th>
<th>
<p>Match (subject)</p>
</th>
<th>
<p>Not match (subject)</p>
</th>
<th>Comment</th>
</tr>
<tr>
<td>world</td>
<td>Hello world</td>
<td>Hello Jim</td>
<td>Match if the pattern is present anywhere in the subject</td>
</tr>
<tr>
<td>^world</td>
<td>world class</td>
<td>Hello world</td>
<td>Match if the pattern is present at the beginning of the subject</td>
</tr>
<tr>
<td>world$</td>
<td>Hello world</td>
<td>world class</td>
<td>Match if the pattern is present at the end of the subject</td>
</tr>
<tr>
<td>world/i</td>
<td>This WoRLd</td>
<td>Hello Jim</td>
<td>Makes a search in case insensitive mode</td>
</tr>
<tr>
<td>^world$</td>
<td>world</td>
<td>Hello world</td>
<td>The string contains only the "world"</td>
</tr>
<tr>
<td>world*</td>
<td>worl, world, worlddd</td>
<td>wor</td>
<td>There is 0 or more "d" after "worl"</td>
</tr>
<tr>
<td>world+</td>
<td>world, worlddd</td>
<td>worl</td>
<td>There is at least 1 "d" after "worl"</td>
</tr>
<tr>
<td>world?</td>
<td>worl, world, worly</td>
<td>wor, wory</td>
<td>There is 0 or 1 "d" after "worl"</td>
</tr>
<tr>
<td>world{1}</td>
<td>world</td>
<td>worly</td>
<td>There is 1 "d" after "worl"</td>
</tr>
<tr>
<td>world{1,}</td>
<td>world, worlddd</td>
<td>worly</td>
<td>There is 1 ore more "d" after "worl"</td>
</tr>
<tr>
<td>world{2,3}</td>
<td>worldd, worlddd</td>
<td>world</td>
<td>There are 2 or 3 "d" after "worl"</td>
</tr>
<tr>
<td>wo(rld)*</td>
<td>wo, world, worldold</td>
<td>wa</td>
<td>There is 0 or more "rld" after "wo"</td>
</tr>
<tr>
<td>earth&#124;world</td>
<td>earth, world</td>
<td>sun</td>
<td>The string contains the "earth" or the "world"</td>
</tr>
<tr>
<td>w.rld</td>
<td>world, wwrld</td>
<td>wrld</td>
<td>Any character in place of the dot.</td>
</tr>
<tr>
<td>^.{5}$</td>
<td>world, earth</td>
<td>sun</td>
<td>A string with exactly 5 characters</td>
</tr>
<tr>
<td>[abc]</td>
<td>abc, bbaccc</td>
<td>sun</td>
<td>There is an "a" or "b" or "c" in the string</td>
</tr>
<tr>
<td>[a-z]</td>
<td>world</td>
<td>WORLD</td>
<td>There are any lowercase letter in the string</td>
</tr>
<tr>
<td>[a-zA-Z]</td>
<td>world, WORLD, Worl12</td>
<td>123</td>
<td>There are any lower- or uppercase letter in the string</td>
</tr>
<tr>
<td>[^wW]</td>
<td>earth</td>
<td>w, W</td>
<td>The actual character can not be a "w" or "W"</td>
</tr>
</tbody>
</table>
<p>The <em>Preg_Match</em> PHP function is used to search a string, and return a 1 or 0. If the search was successful a 1 will be returned, and if it was not found a 0 will be returned. Although other variables can be added, it is most simply phrased as: <strong>preg_match(search_pattern, your_string)</strong>.  The search_pattern needs to be a regular expression.  If you are unfamiliar with them this article gives you an overview of the syntax.</p>
<pre>
&#60;?php
$data = "I had a box of cerial for breakfast today, and then I drank some juice.";
if (preg_match("/juice/", $data))
{
echo "You had juice.";
}
else
{
echo "You had did not have juice.";
}
if (preg_match("/eggs/", $data))
{
echo "You had eggs.";
}
else
{
echo "You had did not have eggs.";
}
?&#62;
</pre>
<p>The code above uses preg_match to check for a key word (first juice then egg) and replies based on whether it is true (1) or false (0).</p>
<p>Another example<br />
regular expression to validate time</p>
<pre>
// Must have one and only one space...
"/(0[1-9]¦1[0-2]):[0-5][0-9] ([ap]m¦[AP]M)/"
// Must have at least one space...
"/(0[1-9]¦1[0-2]):[0-5][0-9]\s+([ap]m¦[AP]M)/"
</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[negative lookbehind regular expression]]></title>
<link>http://rschmid.wordpress.com/2009/10/19/negative-lookbehind-regular-expression/</link>
<pubDate>Mon, 19 Oct 2009 14:08:06 +0000</pubDate>
<dc:creator>rschmid</dc:creator>
<guid>http://rschmid.wordpress.com/2009/10/19/negative-lookbehind-regular-expression/</guid>
<description><![CDATA[testing, that an url is ending in *.seam, except debug.seam -&gt; in one regex def list = ["hallo.se]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>testing, that an url is ending in *.seam, except debug.seam -&#62; in one regex</p>
<p><code><br />
def list = ["hallo.seam":true,"test.debug.seam":false,"test.seam":true,"debug.seam":false,"g.seam":true,"debug.test.seam":true,"test.seam":true,"debug.seam":false,"test.do":false]<br />
def pattern = ~/.*\.seam(?&#60;!debug\.seam)/<br />
for (key in list.keySet()){<br />
    ret = pattern.matcher(key).matches()<br />
    assert ret==list[key]<br />
}<br />
</code></p>
</div>]]></content:encoded>
</item>

</channel>
</rss>
