I'm new to Scala and trying to parse a very simple String and get every character until encountering "--batch" with the following String parser:
def getEntireMetaData : Parser[EntireMetaData] = """(?s).+?(?=--batch)""".r ^^ { EntireMetaData}
And I call it as the following:
val batchRequest: String = "POST /service/$batch HTTP/1.1 \nHost: host \n +
"Content-Type: multipart/mixed;boundary=batch_36522ad7-fc75-4b56-8c71-56071383e77b\n \n" +
"--batch_36522ad7-fc75-4b56-8c71-56071383e77b "
implicit val p = parser.getEntireMetaData
parser.parseAll(p, batchRequest) match {
case result: parser.Success[_] => println(result.get)
case result: parser.NoSuccess => fail(result.toString)
}
which gives me the error
[7.1] failure: string matching regex `\z' expected but `-' found
--batch_36522ad7-fc75-4b56-8c71-56071383e77b
^
The following is what I want my parser to match:
"POST /service/$batch HTTP/1.1 \nHost: host \n +
"Content-Type: multipart/mixed;boundary=batch_36522ad7-fc75-4b56-8c71-56071383e77b\n \n"
Please help me sort this out.
Thanks in advance