PoorLuzer has asked for the wisdom of the Perl Monks concerning the following question:
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
Assumption : The filesize is never > 9999.99MB10.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
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)?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex hackery
by markkawika (Monk) on Jun 12, 2009 at 18:33 UTC | |
by ikegami (Patriarch) on Jun 12, 2009 at 18:46 UTC | |
|
Re: Regex hackery
by ikegami (Patriarch) on Jun 12, 2009 at 18:03 UTC | |
by graff (Chancellor) on Jun 13, 2009 at 17:01 UTC | |
by ikegami (Patriarch) on Jun 13, 2009 at 20:40 UTC | |
by Your Mother (Archbishop) on Jun 14, 2009 at 05:07 UTC | |
|
Re: Regex hackery
by planetscape (Chancellor) on Jun 13, 2009 at 12:27 UTC | |
by PoorLuzer (Beadle) on Jun 14, 2009 at 00:53 UTC |