Page 1 of 1

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

Posted: 16 Sep 2016, 09:58
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!!

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

Posted: 16 Sep 2016, 10:49
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!!!'}

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

Posted: 06 Oct 2016, 04:58
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!!