Skip to content

Instantly share code, notes, and snippets.

@philwills
Created December 5, 2016 17:08
Show Gist options
  • Save philwills/d52701819f07284bc720ab1a91da74a0 to your computer and use it in GitHub Desktop.
Save philwills/d52701819f07284bc720ab1a91da74a0 to your computer and use it in GitHub Desktop.
Everything except a suffix in fastparse
import fastparse.all._
val suffix = P(" end" ~ End)
val parser = P((!suffix ~ AnyChar).rep.! ~ suffix)
parser.parse("start end")
// fastparse.core.Parsed[String,Char,String] = Success(start,9)
parser.parse("start end ")
// fastparse.core.Parsed[String,Char,String] = Failure(" end":1:11 ..."")
parser.parse("start en")
// fastparse.core.Parsed[String,Char,String] = Failure(" end":1:9 ..."")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment