<?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>perl &#8211; stoimen&#039;s web log</title>
	<atom:link href="/tag/perl/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>on web development</description>
	<lastBuildDate>Tue, 13 Feb 2018 08:18:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.3</generator>
	<item>
		<title>Perl Regular Expressions</title>
		<link>/2007/10/17/perl-regular-expressions/</link>
		<comments>/2007/10/17/perl-regular-expressions/#comments</comments>
		<pubDate>Wed, 17 Oct 2007 11:45:53 +0000</pubDate>
		<dc:creator><![CDATA[stoimen]]></dc:creator>
				<category><![CDATA[featured]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">/archives/4</guid>
		<description><![CDATA[perl regular expressions<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/04/23/zend_controller_router_route_regex-the-power-of-regular-expressions/" rel="bookmark" title="Zend_Controller_Router_Route_Regex &#8211; the Power of Regular Expressions">Zend_Controller_Router_Route_Regex &#8211; the Power of Regular Expressions </a></li>
<li><a href="/2010/04/17/css-word-wrap-to-wrap-long-words/" rel="bookmark" title="CSS word-wrap to Wrap Long Words">CSS word-wrap to Wrap Long Words </a></li>
<li><a href="/2010/06/27/four-things-to-know-when-writing-comments/" rel="bookmark" title="Four Things to Know when Writing Comments">Four Things to Know when Writing Comments </a></li>
<li><a href="/2010/04/26/mysql-expressions-in-zend-framework/" rel="bookmark" title="MySQL Expressions in Zend Framework">MySQL Expressions in Zend Framework </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>For everyone who did write a code someday comes the question of using regular expressions. Almost everybody has heart about automatic and regular languages. Assume you have all word for a given languages, which means all possible combination between the letters of a given alphabet. For all these possible word only few construct the &#8220;language&#8221; as we know this term. Of course there&#8217;s also need of grammatic, etc. But however we have the set of words in a given language.</p>
<p>Than comes the task to find those of the words of the language that match a given condition. In fact the regular expressions are a powerful tool to do this job.</p>
<p>Using PHP you can use preg_ functions, which will perform a perl regular expressions match.  In my case I had to find in about 180 .html files specific words.</p>
<p>Assume the files contain something like:</p>
<pre>&lt;!-- wellformed html comment --&gt;</pre>
<pre>&lt;tr&gt;</pre>
<pre>&lt;td class="classname1"&gt;&lt;img ...&gt;&lt;/td&gt;

&lt;td class="classname2"&gt;

&lt;a ... &gt;

Word to match

&lt;/a&gt;

&lt;/td&gt;

&lt;/tr&gt;

&lt;tr&gt;

&lt;td ...&gt;&lt;/td&gt;

&lt;td ...&gt;&lt;/td&gt;

&lt;/tr&gt;

&lt;!--wellformed html comment--&gt;</pre>
<p>The regular expressions for <strong>preg_replace</strong> function I used was something like this:</p>
<pre>'/^[t|s]*&lt;tr&gt;.*?$n^.*?&lt;td.*?&lt;/td&gt;.*?$n.*?</pre>
<pre>&lt;td.*?$n.*?&lt;a.*?&gt;.*?$n.*?Word  to  match.*?$n.*?&lt;/a&gt;.*$n.*?&lt;/td&gt;.*$n.*?</pre>
<pre>&lt;/tr&gt;.*$n.*?&lt;tr.*$n.*?&lt;td.*$n.*?&lt;td.*$n.*?&lt;/tr&gt;/m'</pre>
<p>&#8230; and it worked for me. In fact if you use &#8216;s&#8217; instead of &#8216;m&#8217; modifier that&#8217;s gonna be you mistake cause of the multiple matches before the current tag you want to match.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/04/23/zend_controller_router_route_regex-the-power-of-regular-expressions/" rel="bookmark" title="Zend_Controller_Router_Route_Regex &#8211; the Power of Regular Expressions">Zend_Controller_Router_Route_Regex &#8211; the Power of Regular Expressions </a></li>
<li><a href="/2010/04/17/css-word-wrap-to-wrap-long-words/" rel="bookmark" title="CSS word-wrap to Wrap Long Words">CSS word-wrap to Wrap Long Words </a></li>
<li><a href="/2010/06/27/four-things-to-know-when-writing-comments/" rel="bookmark" title="Four Things to Know when Writing Comments">Four Things to Know when Writing Comments </a></li>
<li><a href="/2010/04/26/mysql-expressions-in-zend-framework/" rel="bookmark" title="MySQL Expressions in Zend Framework">MySQL Expressions in Zend Framework </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2007/10/17/perl-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
