[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



Most regular expressions are ambiguous.  This one just specifies a "/"
followed by one or more characters.  Since there are 4 "/" characters
followed by other characters in the input text, there are 4 ways that
this regexp can match:

opt/SAM/SystemConfig/vtun.pl
SAM/SystemConfig/vtun.pl
SystemConfig/vtun.pl
vtun.pl

By default, subpatterns in perl regexps are "greedy", which means they
will attempt to match as many characters as possible.  This gives the
first match above.

What you really want though is a regexp that specifies a "/" character,
followed by one or more characters that are not a "/":

m{/([^/]+)$}

HTH,
Jason
-- 
Jason Day                                       jasonday at
<a  rel="nofollow" href="http://jasonday.home.att.net";>http://jasonday.home.att.net</a>                    worldnet dot att dot net
 
&quot;Of course I'm paranoid, everyone is trying to kill me.&quot;
    -- Weyoun-6, Star Trek: Deep Space 9


</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00324" href="msg00324.html">[ale] Perl Regexe questions</a></strong>
<ul><li><em>From:</em> cfowler at outpostsentinel.com (Christopher Fowler)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00348.html">[ale] Serializing perl objects</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00350.html">[ale] Serializing perl objects</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00340.html">[ale] Perl Regexe questions</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00329.html">[ale] ssl tools</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00349"><strong>Date</strong></a></li>
<li><a href="threads.html#00349"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>