Here's a challenge (taken from upcoming Volume II) that I need help on.. I would like to include alternatives
to my failed attempt and maybe even using BRC (Bru are you listening) or JavaScript (Admin - up to a challenge)?
So here it is:
-------------------------
Just for Fun – an Impossible Task – Append Initials of Song Title to end of Filename
Perhaps this can be done in Javascript – but not in RegEx as far as I can tell. But here it is anyway. I thought I would
give it a try since it was similar to another challenge I did:
Sample:
SunFly116_12-The Beatles- I Want To Hold Your Hand.mkv to SunFly116_12-The Beatles- I Want To Hold Your Hand-IWTHYH.mkv
Observation:
1. Impossible – Yes I think so. Any challengers out there who can do better? Post it in the forum.
2. The Poster wants to take each initial from each word that makes up the song title and append this to the end of the
same filename.
Why impossible?
1. Unknown variables of how many words will make up the title. No pattern.
2. Only have 9 Capture Groups available.
3. After taking each initial and reached EOF, I cannot in my experience think of how to backtrack enough to capture the
last part of the string when the expression has already been satisfied.
So for S&** and Giggles I base my RegEx on the only (Thank God) sample given.
It is not correct because, although my results are good, they remain incomplete. I am only able to append to the end of
the first part of the filename.
TaDah!
Match: (.*)-*- ([A-Z]).+?([A-Z]).+?([A-Z]).+?([A-Z]).+?([A-Z]).+?([A-Z])(.*)
Replace: \1-\2\3\4\5\6\7
Final Note:
This is so limited it can only be matched with a filename that has exactly 6 words in the title.
------------------------------
So there you have it - my failed attempt - so limited, so restrictive and not even the full solution. I require
successful solutions and much more universal than the solution limited to 6 words in the title.
Personally I think BRC can handle it because it can handle multiple RegEx's so more than 6 words should be no problem. JavaScript
could also handle it - but I would like to see successful BRU RegEx's as well that would allow me to exclaim happily, 'I was Wrong' when I stated
emphatically that it was impossible to do it in BRU.
Also you must provide that your solution works on more than just the single sample I have here.
Thanks in advance and let the challenge begin.