in reply to RE: Re: Easier way to do this
in thread Easier way to do this
The regular expression is simply wrong :-). A regular expression that matches everything with the extension .mp3 would be for example :
/\.mp3$/
A quick explanation : The \.mp3 part is to ask for a literal dot followed by mp3 and the $ part is that the string must end after this. This is also the shortest regular expression that will match all files with an extension of .mp3.
Another regular expression, more in the spirit of the faulty RE would have been
in which you'll recognize the \.mp3$ part from above plus the .* part, which means "match an arbitrary character" (the dot) "zero or more times" (the star)./.*\.mp3$/
As a Perl newbie, getting familiar with regular expressions is quite a task, but you can never start too early with them - in fact, I like Perl as it is the only language I know with REs built into the language core :-)
Some recommended reading on regular expressions is the RE man page and of course the book "Mastering Regular Expressions" by Jeffrey Friedel - but that one contains more about REs than you ever thought there is to know.
|
|---|