<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Thanks. <BR>
&nbsp;<BR>
import Text.ParserCombinators.Parsec <BR>
&nbsp;<BR>
simple = between (char '"') (char '"') (many (satisfy (/= '"')))<BR><BR>
multiple = sepBy simple (char ',') <BR>total&nbsp;&nbsp;&nbsp;&nbsp; = sepBy multiple (char <A href="mailto:'@'">'@'</A>) <BR>
&nbsp;<BR>
str2lsts :: String -&gt; [[String]]<BR>str2lsts str= case parse total "" str of<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Left err -&gt; error (show err)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Right lsts -&gt; lsts<BR>
&nbsp;<BR>
solves my problem. As you can see I've replaced '§' with <A href="mailto:'@'">'@'</A>&nbsp;and now all works fine.<BR>
&nbsp;<BR>
Luca.&nbsp;<BR>&nbsp;<BR>&gt; From: daniel.is.fischer@web.de<BR>&gt; To: beginners@haskell.org<BR>&gt; Subject: Re: [Haskell-beginners] beginner question<BR>&gt; Date: Fri, 30 Oct 2009 15:46:33 +0100<BR>&gt; <BR>&gt; Am Freitag 30 Oktober 2009 14:40:13 schrieb Luca Ciciriello:<BR>&gt; &gt; Hi all.<BR>&gt; &gt;<BR>&gt; &gt; Just a very basic question.<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt; I need to write a function str2lsts :: String -&gt; [[String]] in order to<BR>&gt; &gt; transorm a string like:<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt; "\"1\",\"cat\",\"dog\"§\"2\",\"duck\",\"goose\""<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt; in the list of lists:<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt; [["1","cat","dog"],["2","duck","goose"]]<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt; I've tried to mix recursion, pattern matching and list comprehension, but<BR>&gt; &gt; the obtained result was embarrassing complex (&gt; 20 lines of awful code). I<BR>&gt; &gt; think that a more simple solution certainly exists.<BR>&gt; &gt;<BR>&gt; <BR>&gt; splitOnToken :: Eq a =&gt; a -&gt; [a] -&gt; [[a]]<BR>&gt; splitOnToken t xs<BR>&gt; = case break (== t) xs of<BR>&gt; (hd,tl) -&gt; hd:case tl of<BR>&gt; (_:r@(_:_)) -&gt; splitOnToken t r<BR>&gt; _ -&gt; []<BR>&gt; <BR>&gt; str2lsts = map (map read . splitOnToken ',') . splitOnToken '§'<BR>&gt; <BR>&gt; if things weren't enclosed in quotation marks inside the string, it would be the nicer<BR>&gt; <BR>&gt; map (splitOnToken ',') . splitOnToken '§'<BR>&gt; <BR>&gt; , provided of course, neither ',' nor '§' are valid characters for the target strings.<BR>&gt; <BR>&gt; import Text.ParserCombinators.Parsec<BR>&gt; <BR>&gt; simple = between (char '"') (char '"') (many (staisfy (/= '"')))<BR>&gt; -- alternative: simple = char '"' &gt;&gt; manyTill anyChar (char '"')<BR>&gt; <BR>&gt; multiple = sepBy simple (char ',')<BR>&gt; <BR>&gt; total = sepBy multiple (char '§')<BR>&gt; <BR>&gt; str2lsts str<BR>&gt; = case parse total "" str of<BR>&gt; Left err -&gt; error (show err)<BR>&gt; Right lsts -&gt; lsts<BR>&gt; <BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt; Thanks in advance for any idea.<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt; Luca<BR>&gt; <BR>&gt; <BR>&gt; _______________________________________________<BR>&gt; Beginners mailing list<BR>&gt; Beginners@haskell.org<BR>&gt; http://www.haskell.org/mailman/listinfo/beginners<BR>                                               <br /><hr />Download Messenger onto your mobile for free. <a href='http://clk.atdmt.com/UKM/go/174426567/direct/01/' target='_new'>Learn more.</a></body>
</html>