split on space or -

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

split on space or -

Roelof
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

Reply | Threaded
Open this post in threaded view
|

Re: split on space or -

Pharo Smalltalk Users mailing list
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 <[hidden email]> 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

Reply | Threaded
Open this post in threaded view
|

Re: split on space or -

Nicolai Hess-3-2
In reply to this post by 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 <[hidden email]>:
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

Reply | Threaded
Open this post in threaded view
|

Re: split on space or -

Pharo Smalltalk Users mailing list
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 <[hidden email]> 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 <[hidden email]>:
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

Reply | Threaded
Open this post in threaded view
|

Re: split on space or -

Roelof
In reply to this post by Nicolai Hess-3-2
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 <[hidden email]>:
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


Reply | Threaded
Open this post in threaded view
|

Re: split on space or -

Roelof
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 <[hidden email]>:
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



Reply | Threaded
Open this post in threaded view
|

Re: split on space or -

Nicolai Hess-3-2
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 <[hidden email]>:
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 <[hidden email]>:
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