On approximately 9/25/2003 6:45 AM, came the following characters from
the keyboard of Xu, Qiang (XSSC SGP):

Hi, all:

I have a regular expression that I can't understand.

Suppose $filename is a file name that includes the full path. Say, it is
"/u/scan/abc.jpg", The regular expression is: $filename =~ s|.*/||;


I only know regular expressions such as s/.../.../, but this has the form of
s|...|...| which I am confuse with.


Anyone can explain the above regular expression as detailed as possible?

Any delimiter can be used (other posters were correct about that). The delimiter used affects which delimiter character would need to be escaped in the regular expression. Generally, if something other than / is used as the delimiter character, it is chosen because it doesn't appear in the regular expression, so that there is no need to escape the delimiter character. Some exceptions to that rule include delimiter characters that add additional semantics, such as '.


The expression in this case is stripping off leading directory names, probably hoping to leave an unqualified file name in the "$filename" variable. (Other posters claimed it was stripping the extension, but that is incorrect.)

--
Glenn -- http://nevcal.com/
===========================
Like almost everyone, I receive a lot of spam every day, much of it
offering to help me get out of debt or get rich quick.  It's ridiculous.
-- Bill Gates

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to