subStrings:'|' vs subStrings:'||'

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

subStrings:'|' vs subStrings:'||'

tty
Hi all.

*' Middle-left-cell || style="width: 14em;" | Middle-center-cell ||
Middle-right-cell' self subStrings:'|'
' Middle-left-cell || style="width: 14em;" | Middle-center-cell ||
Middle-right-cell' self subStrings:'||'*

inspect both, they are identical.

Is this expected behavior?

Looking at the method:
char := sourceStream next.

is the "problem" in that a match is had for the single pipe character.

Is there a better way to split that string along double pipes '||'  ?

thank you in advance.





--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
tty
Reply | Threaded
Open this post in threaded view
|

Re: subStrings:'|' vs subStrings:'||'

tty
I found a workaround:

(self copyReplaceTokens: '||' with:'@') subStrings:'@'

Where the copyReplaceTokens: with: message replaces the double pipes. then
the subStrings:'@' gives me the result I was looking for:

#(' Middle-left-cell ' ' style="width: 14em;" | Middle-center-cell ' '
Middle-right-cell')





--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: subStrings:'|' vs subStrings:'||'

Ron Teitelbaum
explode works too!

' Middle-left-cell || style="width: 14em;" | Middle-center-cell || Middle-right-cell' explode: '||' 

an OrderedCollection(' Middle-left-cell ' ' style="width: 14em;" | Middle-center-cell ' ' Middle-right-cell')

make it back into a string with mergeDelimited: ''

:)

All the best,

Ron Teitelbaum

On Thu, Oct 24, 2019 at 12:49 PM tty <[hidden email]> wrote:
I found a workaround:

(self copyReplaceTokens: '||' with:'@') subStrings:'@'

Where the copyReplaceTokens: with: message replaces the double pipes. then
the subStrings:'@' gives me the result I was looking for:

#(' Middle-left-cell ' ' style="width: 14em;" | Middle-center-cell ' '
Middle-right-cell')





--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
tty
Reply | Threaded
Open this post in threaded view
|

Re: subStrings:'|' vs subStrings:'||'

tty
Ron,

Thank you!



--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners