I'm trying FastParse library, but, I'm not sure then is the correct library for what I want to do.
In my test, I'm looking for a 'data' put in the middle of text paragraph, the text is this:
INTEL SSD 180 GB Serie 540s Interfaccia Sata III 6 Gb / s 2.5"
I'm trying to capture the value "180 GB", but, after different intents, I'm not sure if it's possible.
A bit of code:
lazy val spaceSep = "\t" | " " | "\r" | "\n" | "\u000C"
val digits = P(CharIn('0' to '9').rep(1).!).map(_.toInt)
lazy val GBSymbol = P( IgnoreCase("gb") | IgnoreCase("gigabyte"))
lazy val GB = P( AnyChar.rep ~ digits.! ~ spaceSep.rep ~ GBSymbol)
testFastParse.GB.parse("INTEL SSD 180 GB Serie 540s Interfaccia Sata III 6 Gb / s 2.5\"")
The last error "is scala.MatchError: Failure(CharIn("0123456789"):1:63 ..."") (of class fastparse.core.Parsed$Failure)"
Can anyone help me? thank you in advance
AnyChar.repwill not work in here since when start withAnyChar.rep, it's not possible to backtrack. if it's always start with theALPHAmaybe you can do it like:and also need to call out
digits.!is unnecessary in there, since it's already captured bydigitsparser.