Re: Problem with split()

new topic     » goto parent     » topic index » view thread      » older message » newer message
andreasWagner said...

perhaps good to know:

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

Hmm, yeah the Phix version decrements and checks limit before adding each segment whereas the Euphoria code (at least the one I just looked at) adds then checks.

Phix said...
?split("John,Middle,Doe",",",limit:=1) -- {"John,Middle,Doe"} 

You could say that's weird, or you could say that Euphoria has no way to specify "zero splits", not that I can think of a case where the latter might be useful, then again to the best of my recollection I've never found any use for limit, at all.

Also, Phix does not add (or count) empty segments and later strip them:

Phix said...
?split("John;;;;;;Middle;Name;Doe",";",limit:=3) -- {"John","Middle","Name;Doe"} 

Which is not what you'll get from Euphoria - I'll guess {"John",";;;Middle;Name;Doe"} or thereabouts.
I'd argue that's a bigger concern, in that you asked for three items (or 2 with no delimeters) and only gotten two (or 1) back.

PS I switched from commas to semicolons to get round a glitch in that #.#code text#.# stripped me leading commas.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu