Been struggling with a regexp using perl since I couldn't get sed to work as I wanted (mainly "+" sucks with sed).
These are my tests:
# echo cold.case.S01E12.qweqwe |perl -pe 's/^(?:(.*)\.(\d+)x(\d+).*)|(?:(.*)\.S(\d+)E(\d+)).*$/\1 \2 \3 \4 \5 \6 \7/'
cold.case 01 12
#echo cold_case.1x12 | perl -pe 's/^(?:(.*)\.(\d+)x(\d+).*)|(?:(.*)\.S(\d+)E(\d+)).*$/\1 \2 \3 \4 \5 \6 \7/'
cold_case 1 12
Notice the three spaces in front of cold.case? It's because I can't get perl to do an alternate match. A friend came up with the following line:
perl -pe 's/(?:^(?<a>.*)\.(?<b>[0-9])+x(?<c>[0-9]+).*$)|(?:^(?<a>.*)\.S(?<b>[0-9]+)E(?<c>[0-9]+).*$)/$+{a} $+{b} $+{c}/'
Which works just fine, if you're running Perl 5.10, and I'm not! Or, it's not in the Gentoo repository yet. So I'll have to wait. Crap!
Place your comment