split on space or -
Hello, For a acronym maker challenge on exercism.io I have to make acronyms. But I see I have to split the parts on space and when it's a word with a - then I have to split on that, Any hint how I can do that ? Roelof
You need to add something like this in class String: rejectForAcronymsWords: aCollectionOfUnwantedWords " 'An example with an unwanted particle at the start of a sentence and also one in the middle'    rejectForAcronymsWords: #('a' 'an' 'the' 'in' 'of' 'at' 'and')    " ^self asLowercase substrings reject: [ :word | aCollectionOfUnwantedWords includes: word] ----------------- Benoît St-Jean Yahoo! Messenger: bstjean Twitter: @BenLeChialeux Pinterest: benoitstjean Instagram: Chef_Benito IRC: lamneth Blogue: endormitoire.wordpress.com "A standpoint is an intellectual horizon of radius zero". (A. Einstein) On Saturday, November 24, 2018, 3:49:56 p.m. EST, Roelof Wobben <r.wobben@home.nl> wrote: Hello, For a acronym maker challenge on exercism.io I have to make acronyms. But I see I have to split the parts on space and when it's a word with a - then I have to split on that, Any hint how I can do that ? Roelof
What have you tried so far? There is a split method in pharo, with examples :) Am Sa., 24. Nov. 2018 um 21:49 Uhr schrieb Roelof Wobben <r.wobben@home.nl>:
Hello,
For a acronym maker challenge on exercism.io I have to make acronyms. But I see I have to split the parts on space and when it's a word with a - then I have to split on that,
Any hint how I can do that ?
Roelof
Nice! Never realized we had that method in the image!!!!! ----------------- Benoît St-Jean Yahoo! Messenger: bstjean Twitter: @BenLeChialeux Pinterest: benoitstjean Instagram: Chef_Benito IRC: lamneth Blogue: endormitoire.wordpress.com "A standpoint is an intellectual horizon of radius zero". (A. Einstein) On Saturday, November 24, 2018, 4:08:09 p.m. EST, Nicolai Hess <nicolaihess@gmail.com> wrote: What have you tried so far?There is a split method in pharo, with examples :) Am Sa., 24. Nov. 2018 um 21:49 Uhr schrieb Roelof Wobben <r.wobben@home.nl>: Hello, For a acronym maker challenge on exercism.io I have to make acronyms. But I see I have to split the parts on space and when it's a word with a - then I have to split on that, Any hint how I can do that ? Roelof
split (or splitOn) are working on characters, but also on regex and blocks! 'Complementary metal-oxide semiconductor' splitOn: '-| ' asRegex. 'Complementary metal-oxide semiconductor' splitOn: [:c | c isSpaceSeparator or:[ c = $-] ]. Am Sa., 24. Nov. 2018 um 22:29 Uhr schrieb Roelof Wobben <r.wobben@home.nl>:
hmm, I can split on the space or on the - but not on both
'Complementary metal-oxide semiconductor' splitOn: '[- ]'
this does nothing
'Complementary metal-oxide semiconductor' splitOn: '- '
does work and
'Complementary metal-oxide semiconductor' splitOn: ' '
does work
Op 24-11-2018 om 22:19 schreef Roelof Wobben:
thanks,
this one looks very promosing : self assert: ('foobar' splitOn: '[aeiou]+'
Roelof
Op 24-11-2018 om 22:07 schreef Nicolai Hess:
What have you tried so far? There is a split method in pharo, with examples :)
Am Sa., 24. Nov. 2018 um 21:49 Uhr schrieb Roelof Wobben <r.wobben@home.nl
:
Hello,
For a acronym maker challenge on exercism.io I have to make acronyms. But I see I have to split the parts on space and when it's a word with a - then I have to split on that,
Any hint how I can do that ?
Roelof
participants (3)
-
Benoit St-Jean -
Nicolai Hess -
Roelof Wobben