Jump to content

Tokenize a string: Difference between revisions

(add m4)
Line 370:
output parse map [ifelse ? = :sep ["| |] [?]] :str
end</lang>
 
This form is more robust, doing the right thing if there are embedded spaces.
<lang logo>
to split :str :by [:acc []] [:w "||]
if empty? :str [output lput :w :acc]
ifelse equal? first :str :by ~
[output (split butfirst :str :by lput :w :acc)] ~
[output (split butfirst :str :by :acc lput first :str :w)]
end
</lang>
 
<lang logo> ? show split "Hello,How,Are,You,Today ",
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.