[HELP] How to Extract The First First Character From Each Word in The Title

All about user-defined episode / movie / file name format expressions
Post Reply
Romtromon
Posts: 25
Joined: 16 Sep 2016, 09:51

[HELP] How to Extract The First First Character From Each Word in The Title

Post by Romtromon »

I think the subject explains it for the most part but let me give you a few examples just to make it clear.

"The Shawshank Redemption" would become "TSR"
"The Exorcism of Emily Rose" would become "TEoER" (Note that I want it to be case-sensitive)
"Haikyuu!!" would become "H!!" (Note that I want to retain punctuation and other special characters)

I have a feeling this might be fairly tough to do and I have no experience with Groovy or Java myself. I'd greatly appreciate any help!!
User avatar
rednoah
The Source
Posts: 23030
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [HELP] How to Extract The First First Character From Each Word in The Title

Post by rednoah »

Option 1:
Use the String.acronym() function:

Code: Select all

'The Exorcism of Emily Rose!!!'.acronym() == 'EOER'
Not exactly what you want, but easy. :geek:


Option 2:
Be a cool coder:

Code: Select all

{'The Exorcism of Emily Rose!!!'.matchAll(/\b\w|[!?]/).join() == 'TEoER!!!'}
OR

Code: Select all

{'The Exorcism of Emily Rose!!!'.replaceAll(/(?<=\w)[\w\s]/, '') == 'TEoER!!!'}
:idea: Please read the FAQ and How to Request Help.
Romtromon
Posts: 25
Joined: 16 Sep 2016, 09:51

Re: [HELP] How to Extract The First First Character From Each Word in The Title

Post by Romtromon »

This is amazing thank you so much!! I should really read into Groovy cause seems like practically anything is possible! Thanks again you've been a big help!!
Post Reply