Lihn, Steve wrote:
> Programmer with perl background would think split like:
> <list of string> = split <regex> <original string>
> Since regex is involved, it is specific to (Byte)String, not a generic
> list. Also it appears one would need help from Text.Regex(.PCRE) to do
>> intercalate a (split a xs) = a
> This identity rule does not hold for perl's join/split if regex is used.
Well, libpcre does not have a split function.
One can already write a split that uses the high level Regex API. The only
reason you might want to dig into regex-pcre's Text.Regex.PCRE would be if it
would help efficiency.
Specifically, regex-base defines a RegexContext instance which is:
( RegexLike a b => RegexContext a b (b, b, b) ) : The text before the match, the
text of the match, the text after the match
So you can iteratively generate the pieces that split returns.
Haskell-Cafe mailing list