<?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>Inparablog &#187; Regexp</title>
	<atom:link href="http://www.myscience.nl/index.php/tag/regexp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.myscience.nl</link>
	<description>A comparative genomics and bioinformatics blog</description>
	<lastBuildDate>Wed, 07 Oct 2009 11:52:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=7557</generator>
		<item>
		<title>Retrieving an unknown number of backreferences</title>
		<link>http://www.myscience.nl/index.php/2008/07/28/retrieving-an-unknown-number-of-backreferences/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=retrieving-an-unknown-number-of-backreferences</link>
		<comments>http://www.myscience.nl/index.php/2008/07/28/retrieving-an-unknown-number-of-backreferences/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 13:28:38 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Backreferences]]></category>
		<category><![CDATA[Regexp]]></category>
		<category><![CDATA[Regular Expressions]]></category>

		<guid isPermaLink="false">http://www.myscience.nl/?p=88</guid>
		<description><![CDATA[I have been racking my brains over this, but could not find help anywhere. It seems that doing wacky stuff in Perl out of desperation actually pays off! I wanted to search a string using this regexp without knowing how many matches I would find: $string =~ /\(\d+):/g This would match &#8217;15&#8242;  and &#8217;20&#8242; in [...]]]></description>
			<content:encoded><![CDATA[<p>I have been racking my brains over this, but could not find help anywhere. It seems that doing wacky stuff in Perl out of desperation actually pays off!</p>
<p>I wanted to search a string using this regexp without knowing how many matches I would find:</p>
<p><code>$string =~ /\(\d+):/g</code></p>
<p>This would match &#8217;15&#8242;  and &#8217;20&#8242; in a string which looks like this :</p>
<p><code>$string = "(yeast:0.12313,((zebrafish:0.12312,fugu:0.84134)15:0.52313,<br />
human:0.94424)20:0.93313);";</code></p>
<p>One can access the found values by using backreferences (in this case $1 and $2). But what if you do not know how many backreferences there are?</p>
<p>This piece of perl code will return the values of all the backreferences:</p>
<p><code>my @array;<br />
while ($string =~ /\)(\d+):/g) {<br />
         push @array, $1;<br />
}</code></p>
<p>@array will contain the values of all the backreferences. Don&#8217;t ask me why this works&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.myscience.nl/index.php/2008/07/28/retrieving-an-unknown-number-of-backreferences/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
