<?xml version="1.0" encoding="windows-1252"?>
<node id="1006103" title="Re: Wild card in regular expression" created="2012-11-28 16:14:04" updated="2012-11-28 16:14:04">
<type id="11">
note</type>
<author id="622051">
toolic</author>
<data>
<field name="doctext">
&lt;p&gt;Tip #9 from the [Basic debugging checklist] : [mod://YAPE::Regex::Explain|&lt;c&gt;YAPE::Regex::Explain&lt;/c&gt;]

&lt;c&gt;
The regular expression:

(?-imsx:(ther*))

matches as follows:
  
NODE                     EXPLANATION
----------------------------------------------------------------------
(?-imsx:                 group, but do not capture (case-sensitive)
                         (with ^ and $ matching normally) (with . not
                         matching \n) (matching whitespace and #
                         normally):
----------------------------------------------------------------------
  (                        group and capture to \1:
----------------------------------------------------------------------
    the                      'the'
----------------------------------------------------------------------
    r*                       'r' (0 or more times (matching the most
                             amount possible))
----------------------------------------------------------------------
  )                        end of \1
----------------------------------------------------------------------
)                        end of grouping
----------------------------------------------------------------------
&lt;/c&gt;

&lt;p&gt;Use . instead.  Also, with different delimiters, you can clean up the replacement string:
&lt;c&gt;
use warnings;
use strict;

my $test = "Here is the there";
$test =~ s{(ther.)}{&lt;test&gt;$1&lt;/test&gt;}ig;
print "$test\n";

__END__

Here is the &lt;test&gt;there&lt;/test&gt;
&lt;/c&gt;


</field>
<field name="root_node">
1006098</field>
<field name="parent_node">
1006098</field>
</data>
</node>
