<?xml version="1.0" encoding="windows-1252"?>
<node id="870837" title="Re: Store regular expressions in a file." created="2010-11-11 07:08:21" updated="2010-11-11 07:08:21">
<type id="11">
note</type>
<author id="647953">
sundialsvc4</author>
<data>
<field name="doctext">
&lt;p&gt;
The magic voodoo you are looking for is: &amp;nbsp; &lt;tt&gt;&lt;b&gt;qr/&lt;i&gt;some_expression&lt;/i&gt;/&lt;/b&gt;&lt;/tt&gt;.
&lt;/p&gt;&lt;p&gt;
This operator compiles a regular expression that is made from &lt;tt&gt;&lt;i&gt;some_string&lt;/i&gt;&lt;/tt&gt;.
&lt;/p&gt;&lt;p&gt;
When constructing the string, be careful: &amp;nbsp; you might be tempted to use interpolation (double-quotes...) but this will cause the &amp;ldquo;rabbit-food&amp;rdquo; of the regex syntax itself to be turned into escape-characters.
&lt;/p&gt;&lt;p&gt;
Furthermore, you might find that you can successfully put a string-variable reference &lt;i&gt;into&lt;/i&gt; the regular expression string &lt;i&gt;(i.e.&lt;/i&gt; without using &lt;tt&gt;qr//&lt;/tt&gt;), and find that it is properly interpolated. &amp;nbsp; If you simply want to substitute &amp;ldquo;a particular string to search for&amp;rdquo; into an otherwise-fixed expression, this is one way to do that.
&lt;/p&gt;&lt;p&gt;
If the regexes to be used are truly arbitrary, however, you will want to use &lt;tt&gt;qr//&lt;/tt&gt;, and to enclose that statement in an &lt;tt&gt;eval&lt;/tt&gt; block to trap runtime errors caused by invalid regex syntax.
&lt;/p&gt;</field>
<field name="root_node">
870806</field>
<field name="parent_node">
870806</field>
</data>
</node>
