Re: Problem with split()

new topic     » goto parent     » topic index » view thread      » older message » newer message

Hallo

CraigWelch said...

From the documentation:

Example 2:

result = split("John,Middle,Doe", ",",, 2) -- Only want 2 sub-sequences. 
-- result is {"John", "Middle,Doe"}  

My actual result:

result = split("John,Middle,Doe", ",",, 2) -- Only want 2 sub-sequences. 
-- result is {"John", "Middle", "Doe"}  

However:

result = split("John,Middle,Doe", ",",, 1) -- Only want 2 sub-sequences. 
-- result is {"John", "Middle,Doe"}  

In other words, the 'limit' operator needs to be one less than desired / documented.

This has probably been discussed before.

Here: https://openeuphoria.org/forum/m/131078.wc

perhaps good to know:

Phix apparently adheres to the documentation here and is therefore incompatible in this case.

Andreas

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu