[Haskell-cafe] splitting strings
Thomas Hartman
tphyahoo at gmail.com
Thu Mar 1 12:23:46 EST 2007
I think you want
Text.Regex. splitRegex
or something very much like it.
http://haskell.org/hoogle/?q=String-%3E%5BString%5D
2007/3/1, h. <h._h._h._ at hotmail.com>:
> Hello,
>
> I wrote the following split function for Strings:
>
>
> splitS :: String -> String -> [String]
> splitS a b = splitA a b
> where
> z = length b - 1
> splitA [] _ = [""]
> splitA (c:cs) (d:ds) | c == d && fst s == ds = "" : splitA (snd s) b
> | otherwise = (c : head r) : tail r
> where
> r = splitA cs b
> s = splitAt z cs
>
>
> example: splitS "Test;Hello;+123.5;+ 7" ";+" -> ["Test;Hallo","123.5"," 7"]
>
> How could it be optimized on speed?
> Does there exist already an optimized split for the conventional String
> type?
>
> --
> Thanks in advance for your answer.
> h.
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
More information about the Haskell-Cafe
mailing list