<?xml version="1.0" encoding="windows-1252"?>
<node id="544950" title="Re^2: Regexp: Match anything except a certain word" created="2006-04-21 13:15:18" updated="2006-04-21 09:15:18">
<type id="11">
note</type>
<author id="381608">
ikegami</author>
<data>
<field name="doctext">
&lt;p&gt;That's not how you use the negative lookahead. It won't work. For example,

&lt;c&gt;
'&lt;a href="..." target="..."&gt;' =~ /
   &lt;a            # Matches '&lt;a'.
   .+?           # Matches ' '.
   (?!target)    # Matches. (/\Gtarget/ doesn't match.)
   .+?           # Matches 'href="..." target="..."'.
   &gt;             # Matches '&gt;'.
/isx;
&lt;/c&gt;

and

&lt;c&gt;
'&lt;a target="..." href="..."&gt;' =~ /
   &lt;a            # Matches '&lt;a'.
   .+?           # Matches ' t'.
   (?!target)    # Matches. (/\Gtarget/ doesn't match.)
   .+?           # Matches 'arget="..." href="..."'.
   &gt;             # Matches '&gt;'.
/isx;
&lt;/c&gt;

&lt;p&gt;The common use of a negative lookahead is

&lt;c&gt;
/(?:(?!$re).)*/
&lt;/c&gt;

&lt;p&gt;See [id://544954|my earlier post] for the fix.

</field>
<field name="root_node">
544944</field>
<field name="parent_node">
544948</field>
</data>
</node>
