[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- <!--x-content-type: text/plain -->
- <!--x-date: Wed Jun 16 13:29:32 2004 -->
- <!--x-from-r13: wnfbaqnl ng jbeyqarg.ngg.arg (Xnfba Rnl) -->
- <!--x-message-id: [email protected] -->
- <!--x-reference: [email protected] --> "http://www.w3.org/TR/html4/loose.dtd">
- <!--x-subject: [ale] Perl Regexe questions -->
- <li><em>date</em>: Wed Jun 16 13:29:32 2004</li>
- <li><em>from</em>: jasonday at worldnet.att.net (Jason Day)</li>
- <li><em>in-reply-to</em>: <<a href="msg00324.html">[email protected]</a>></li>
- <li><em>references</em>: <<a href="msg00324.html">[email protected]</a>></li>
- <li><em>subject</em>: [ale] Perl Regexe questions</li>
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
"Of course I'm paranoid, everyone is trying to kill me."
-- 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>