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

/.*\.mp3$/
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).

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.


In reply to RE: RE: Re: Easier way to do this by Corion
in thread Easier way to do this by LoneRanger

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.