In what way is it not working?

Is it running too slowly because the greedy .+ first tries to match the entire file, and then tries the entire file-1, and so on?

Is it removing too much because there is a second // Track in the file that it can match?

Is it removing too little because one of your titles/performers happens to include the sequence // Track (while trying a non-greedy ".+?")?

Without getting into real parsing, I'd suggest starting with a non-greedy +. Match explicitly against the closing bracket and the newlines to reduce (unfortunately not eliminate) the chances of matching something you don't expect, and move the actual // Track check into a lookahead, so that it is not part of the match and won't be deleted. (Also, lookaheads are good to learn for the future)


In reply to Re: regex help, please by SuicideJunkie
in thread regex help, please by mchampag

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.