<?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>MaisonBisson.com &#187; regex</title>
	<atom:link href="http://maisonbisson.com/blog/post/tag/regex/feed/" rel="self" type="application/rss+xml" />
	<link>http://maisonbisson.com</link>
	<description>A bunch of stuff I would have emailed you about.</description>
	<lastBuildDate>Sat, 14 Nov 2009 20:14:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Matching Multi-line Regex in BBEdit</title>
		<link>http://maisonbisson.com/blog/post/13451/matching-regular-expressions-across-multiple-lines-in-bbedit/</link>
		<comments>http://maisonbisson.com/blog/post/13451/matching-regular-expressions-across-multiple-lines-in-bbedit/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 22:17:57 +0000</pubDate>
		<dc:creator>Casey Bisson</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[bbedit]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[regular expressions]]></category>

		<guid isPermaLink="false">http://maisonbisson.com/?p=13451</guid>
		<description><![CDATA[
I love BBEdit on my Mac, but I was left scratching my head again today when I was trying to remember how to make its regex engine match a pattern across multiple lines. My hope was to extract a list of initial articles from a page that had HTML like this:

&#160;
     [...]]]></description>
			<content:encoded><![CDATA[<abbr class="unapi-id" title="maisonbisson-13451"><!-- &nbsp; --></abbr>
<p>I love <a href="http://www.barebones.com/products/bbedit/">BBEdit</a> on my Mac, but I was left scratching my head again today when I was trying to remember how to make its regex engine match a pattern across multiple lines. My hope was to extract a list of initial articles from <a href="http://www.loc.gov/marc/bibliographic/bdapndxf.html">a page that had HTML like this</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&nbsp;
      &lt;table&gt;
         &lt;tr&gt;
            &lt;td valign=&quot;top&quot; colspan=&quot;34&quot; align=&quot;left&quot;&gt;am&lt;/td&gt;
            &lt;td valign=&quot;top&quot; colspan=&quot;10&quot; align=&quot;left&quot;&gt;Scottish Gaelic&lt;/td&gt;
         &lt;/tr&gt;
      &lt;/table&gt;
      &lt;table&gt;
         &lt;tr&gt;
            &lt;td valign=&quot;top&quot; colspan=&quot;34&quot; align=&quot;left&quot;&gt;an&lt;/td&gt;
            &lt;td valign=&quot;top&quot; colspan=&quot;10&quot; align=&quot;left&quot;&gt;English,&lt;/td&gt;
            &lt;td valign=&quot;top&quot; colspan=&quot;10&quot; align=&quot;left&quot;&gt;Irish,&lt;/td&gt;
            &lt;td valign=&quot;top&quot; colspan=&quot;10&quot; align=&quot;left&quot;&gt;Scots,&lt;/td&gt;
            &lt;td valign=&quot;top&quot; colspan=&quot;10&quot; align=&quot;left&quot;&gt;Scottish Gaelic,&lt;/td&gt;
            &lt;td valign=&quot;top&quot; colspan=&quot;10&quot; align=&quot;left&quot;&gt;Yiddish&lt;/td&gt;
         &lt;/tr&gt;
      &lt;/table&gt;
      &lt;table&gt;
         &lt;tr&gt;
            &lt;td valign=&quot;top&quot; colspan=&quot;34&quot; align=&quot;left&quot;&gt;an t-&lt;/td&gt;
            &lt;td valign=&quot;top&quot; colspan=&quot;10&quot; align=&quot;left&quot;&gt;Irish,&lt;/td&gt;
            &lt;td valign=&quot;top&quot; colspan=&quot;10&quot; align=&quot;left&quot;&gt;Scottish Gaelic&lt;/td&gt;
         &lt;/tr&gt;
      &lt;/table&gt;</pre></div></div>

<p>Indeed, it has well over 100 tables like that, and I was looking for the contents of the first TD in each.  The following regex does it:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009900;">&#40;</span>?s<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>^<span style="color: #339933;">&lt;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">*&lt;</span>table<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#91;</span>^<span style="color: #339933;">&lt;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">*&lt;</span>tr<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#91;</span>^<span style="color: #339933;">&lt;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">*&lt;</span>td<span style="color: #009900;">&#91;</span>^<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">*&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>^<span style="color: #339933;">&lt;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&lt;/</span>td<span style="color: #339933;">&gt;.*</span>?<span style="color: #339933;">&lt;/</span>table<span style="color: #339933;">&gt;</span></pre></div></div>

<p>The most significant part of this is the <code>(?s)</code> at the beginning that tells BBEdit to match the pattern across line breaks. A more ninja-like regex assassin would probably be able to do it better, but this worked.</p>
]]></content:encoded>
			<wfw:commentRss>http://maisonbisson.com/blog/post/13451/matching-regular-expressions-across-multiple-lines-in-bbedit/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>RegEx Reference</title>
		<link>http://maisonbisson.com/blog/post/10651/regex-reference/</link>
		<comments>http://maisonbisson.com/blog/post/10651/regex-reference/#comments</comments>
		<pubDate>Tue, 28 Jun 2005 04:53:00 +0000</pubDate>
		<dc:creator>Casey Bisson</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[ereg_replace]]></category>
		<category><![CDATA[exclusion operator]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[regex reference]]></category>
		<category><![CDATA[regular expressions]]></category>

		<guid isPermaLink="false">http://www.maisonbisson.com/blog/?p=10651</guid>
		<description><![CDATA[
Regular expressions are a pain. Jan Goyvaerts&#8217; RegEx Reference helps.
In a related tip, the following will eliminate any non-numeric components in a string: ereg_replace(“[^0-9]”, “”, $string) . I guess I&#8217;ll have to admit that I&#8217;d not used the exclusion operator before (the carrot immediately following a square bracket). Now I know.

tags: ereg_replace, exclusion operator, php, [...]]]></description>
			<content:encoded><![CDATA[<abbr class="unapi-id" title="maisonbisson-10651"><!-- &nbsp; --></abbr>
<p>Regular expressions are a pain. Jan Goyvaerts&#8217; <a href="http://www.regular-expressions.info/reference.html">RegEx Reference</a> helps.</p>
<p>In a related tip, the following will eliminate any non-numeric components in a string: <span style="font-family:monospace;">ereg_replace(“[^0-9]”, “”, $string)</span> . I guess I&#8217;ll have to admit that I&#8217;d not used the exclusion operator before (the carrot immediately following a square bracket). Now I know.<br />
<!-- technorati tags start -->
<p style="text-align:right;font-size:10px;">tags: <a href="http://technorati.com/tag/ereg_replace" rel="tag">ereg_replace</a>, <a href="http://technorati.com/tag/exclusion operator" rel="tag">exclusion operator</a>, <a href="http://technorati.com/tag/php" rel="tag">php</a>, <a href="http://technorati.com/tag/regex" rel="tag">regex</a>, <a href="http://technorati.com/tag/regex reference" rel="tag">regex reference</a>, <a href="http://technorati.com/tag/regular expressions" rel="tag">regular expressions</a></p>
<p><!-- technorati tags end --></p>
]]></content:encoded>
			<wfw:commentRss>http://maisonbisson.com/blog/post/10651/regex-reference/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>