Imaging i've got following:
--open
Client: enter
Nick
Age 28
Rosewell, USA
Client: enter
Maria
Age 19
Cleveland, USA
--open--
I need a result close to the following: List(List(Nick, Age 28, Rosewell), List(Maria, Age19, Cleveland))
It can be as many clients inside open body as you can imagine, so the list can have any size, it's not fixed.
I was trying to make with the help of following:
repsep(".*".r , "Client: enter" + lineSeparator)
In this case all i can parse it this line List((Client: enter))
, how to make sure that you work with the same piece of parse text?
I guess you are using the
RegexParsers
(just note that it skips white spaces by default). I'm assuming that it ends with"\n\n--open--"
instead (if you can change that otherwise I'll show you how to modify therepsep
parser). With this change we see that the text has the following structure:"Client: enter"
Then the implementation of the parser is straightforward:
Running it with:
You get: