I have been thinking about a regular expression that can transform a list like this:

1. 10.Things.I.Hate.About.You[1999]DvDrip[Eng]-Ray 699.68 MB 2. 100.Feet.2008.DvDRip-FxM 701.14 MB 3. 11 - 14 1 286.22 MB 4. 13_going_on_30(2004)[Brizzly] 700.23 MB ... 1 523. Waz 699.93 MB 1 524. We.Own.the.Night[2007]DvDrip[Eng]-Ray 700.87 MB 1 525. Webs [2003]DVDRip[Xvid AC3[5.1]-RoCK&BlueLadyRG 1 347.70 MB

into:
10.Things.I.Hate.About.You[1999]DvDrip[Eng]-Ray,699.68 MB 100.Feet.2008.DvDRip-FxM,701.14 11 - 14,1286.22 13_going_on_30(2004)[Brizzly],700.23 ... Waz,699.93 We.Own.the.Night[2007]DvDrip[Eng]-Ray,700.87 Webs [2003]DVDRip[Xvid AC3[5.1]-RoCK&BlueLadyRG,1347.70
Assumption : The filesize is never > 9999.99MB

So far I have a partially working regex:

^[^\.]+\. (.+?) (?:([0-9])(?: ))?([0-9]+\.[0-9]{2}) MB.*$

that maps to

$1:$2$3

to complete the transformation.

I used the colon because no desktop OS would allow that in a filename, so I am safe.

I built the regex without any formal method (i.e, via using intution) and that very same intution tells me this regex is horrifically complicated and slow!

I wish RegExBuddy had a online version or something similar.

How do I build a better RegEx for the same? Hints, tips...

Is there any free/open tool that will allow me to profile my regex (except writing a Perl script)?


In reply to Regex hackery by PoorLuzer

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.