Problem with newline as separator

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

Problem with newline as separator

PabloEstefo
Hi everyone,

I needed to split a list of numbers separated by a newline character and I supposed I could get it doing this:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'1
4
9
16
25
36
49
64
81
100' subStrings:  (String cr)  

Result: an Array ('1
4
9
16
25
36
49
64
81
100')
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
But I received an array with one element which is the same string I wanted to split.

When I evaluated manually (String cr) and then split it works:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'1
4
9
16
25
36
49
64
81
100' subStrings:  '
‘  

Result:  an Array ('1' '4' '9' '16' '25' '36' '49' '64' '81' '100')
=-=-=-=-=-=-=-=-=-=-=-=-=-=-

I think this behaviour is weird so I’m reporting it.

Cheers,
Pablo

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with newline as separator

Herby Vojčík
There's String cr and String lf, so it depends what your system uses (maybe crlf, even).

There is also #lines and #linesDo: which you can use for this case.

Herby

Pablo Estefó wrote:

> Hi everyone,
>
> I needed to split a list of numbers separated by a newline character and I supposed I could get it doing this:
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-
> '1
> 4
> 9
> 16
> 25
> 36
> 49
> 64
> 81
> 100' subStrings:  (String cr)
>
> Result: an Array ('1
> 4
> 9
> 16
> 25
> 36
> 49
> 64
> 81
> 100')
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-
> But I received an array with one element which is the same string I wanted to split.
>
> When I evaluated manually (String cr) and then split it works:
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-
> '1
> 4
> 9
> 16
> 25
> 36
> 49
> 64
> 81
> 100' subStrings:  '
> ‘
>
> Result:  an Array ('1' '4' '9' '16' '25' '36' '49' '64' '81' '100')
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-
>
> I think this behaviour is weird so I’m reporting it.
>
> Cheers,
> Pablo
>

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with newline as separator

philippeback
In reply to this post by PabloEstefo
Character cr split:'1
4
9
16
25
36
49
64
81
100'

maybe?

---
Philippe Back
Dramatic Performance Improvements
Mob: +32(0) 478 650 140 | Fax: +32 (0) 70 408 027
Blog: http://philippeback.be | Twitter: @philippeback

High Octane SPRL
rue cour Boisacq 101 | 1301 Bierges | Belgium

Pharo Consortium Member - http://consortium.pharo.org/
Featured on the Software Process and Measurement Cast - http://spamcast.libsyn.com
Sparx Systems Enterprise Architect and Ability Engineering EADocX Value Added Reseller
 



On Tue, Dec 3, 2013 at 7:16 PM, Pablo Estefó <[hidden email]> wrote:
Hi everyone,

I needed to split a list of numbers separated by a newline character and I supposed I could get it doing this:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'1
4
9
16
25
36
49
64
81
100' subStrings:  (String cr)

Result: an Array ('1
4
9
16
25
36
49
64
81
100')
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
But I received an array with one element which is the same string I wanted to split.

When I evaluated manually (String cr) and then split it works:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'1
4
9
16
25
36
49
64
81
100' subStrings:  '


Result:  an Array ('1' '4' '9' '16' '25' '36' '49' '64' '81' '100')
=-=-=-=-=-=-=-=-=-=-=-=-=-=-

I think this behaviour is weird so I’m reporting it.

Cheers,
Pablo

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with newline as separator

baulamon
In reply to this post by PabloEstefo
Hello,
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group