<?xml version="1.0" encoding="windows-1252"?>
<node id="695930" title="Re: Common Regex Gotchas" created="2008-07-07 04:59:11" updated="2008-07-07 00:59:11">
<type id="11">
note</type>
<author id="683288">
rovf</author>
<data>
<field name="doctext">
&lt;p&gt;
Maybe it's worth to include the following, which has bitten me once too: One common use is to get regexp from an external source - for instance, your commandline - into your program, so you end up having somewhere something like:
&lt;code&gt;
if($line =~ /$pattern/) { ... }
&lt;/code&gt;
The trap here is when $pattern happens to be the null string, yielding the Regexp &lt;c&gt;//&lt;/c&gt;. This special regexp, unless it is used as argument to the &lt;c&gt;split&lt;/c&gt; function, means: "Match again the most recently encountered regexps", which can lead to pretty bizarre program behaviour.
&lt;/p&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-683288"&gt;
--&amp;nbsp;&lt;br&gt;
Ronald Fischer &amp;lt;ynnor@mm.st&amp;gt;

&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
9096</field>
<field name="parent_node">
9096</field>
</data>
</node>
