Re: split() function

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

Do a search for CSV or comma separated values.  Or just the word comma.
And, narrow the search to messages by me, Lucius.  You will find that it has
it includes such a tool that is very similar to your split().  It uses an
object, (sequence or atom) as a split delimiter.  It is not currently
available at my website.  I will have to correct that oversight on my part.

        Sincerely, Lucius L. Hilley III
        lhilley at cdc.net   ICQ: 9638898 (memory hog)
                          AIM: LLHIII

> ---------------------- Information from the mail
header -----------------------
> Sender:       Euphoria Programming for MS-DOS
<EUPHORIA at LISTSERV.MUOHIO.EDU>
> Poster:       No Solution <solutionnone at HOTMAIL.COM>
> Subject:      split() function
> --------------------------------------------------------------------------
-----
>
> Hello all .
>
> Anybody that's programmed in perl or PHP knows that the split() function
is
> extremely useful.
>
> When i first downloaded Euphoria, I was suprised that there was no split
> function seeing as it's main datatype can be used to express strings. So
one
> day i set out to write my own split() function, after several bad
attempts,
> i came to a very obvious and efficient function.
>
> here it is :
>
> global function split(atom char,  sequence string)
>   sequence ret
>   integer c
>   ret = {{}}
>   c = 1
>   for i = 1 to length(string) do
>     if string[i] = char then
>       ret = append(ret,{})
>       c = length(ret)
>     else
>       ret[c] &= string[i]
>     end if
>   end for
>   return ret
> end function
>
> so far you can only use atoms to use a delimiters to split strings by.
>
> use the function like this:
>
> sequence s,words
>
> s = "hello!world"
>
> words = split('!',s)
>
> anybody who writes euphoria programs that require text parsing would find
> this function extremely useful,if they haven't written it already.
>
> Ian Smith
>

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

Search



Quick Links

User menu

Not signed in.

Misc Menu