<?xml version="1.0" encoding="windows-1252"?>
<node id="1012770" title="Re: Detecting if a string is a regular expression" created="2013-01-10 19:29:06" updated="2013-01-10 19:29:06">
<type id="11">
note</type>
<author id="171588">
BrowserUk</author>
<data>
<field name="doctext">
&lt;blockquote&gt;&lt;i&gt;&lt;/i&gt;&lt;/blockquote&gt;

&lt;p&gt;To test if a string contains regex metachars, [quotemeta] it and compare it to the original:
&lt;code&gt;
print "$_: does", ($_ eq quotemeta() ? 'not' : '' ), 'contain metachars' 
    for 'a.c', '[abc]', 'abcd';;
a.c: does  contain metachars
[abc]: does  contain metachars
abcd: does not contain metachars
&lt;/code&gt;

&lt;P&gt;Of course, that doesn't test if the metachars make sense as a regex.

&lt;div class="pmsig"&gt;&lt;div class="pmsig-171588"&gt;
&lt;hr /&gt;
&lt;font size=1 &gt;
&lt;div&gt;With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'&lt;/div&gt;
&lt;div&gt;Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.&lt;/div&gt;
&lt;div&gt;"Science is about questioning the status quo. Questioning authority". &lt;/div&gt;
&lt;div&gt;In the absence of evidence, opinion is indistinguishable from prejudice.
&lt;/div&gt;
&lt;/font&gt;

&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1012724</field>
<field name="parent_node">
1012724</field>
</data>
</node>
