Skip to content

Instantly share code, notes, and snippets.

@mcarolan
Created February 17, 2017 15:15
Show Gist options
  • Save mcarolan/c9940dc11e9ef722a05ad027b7d360cd to your computer and use it in GitHub Desktop.
Save mcarolan/c9940dc11e9ef722a05ad027b7d360cd to your computer and use it in GitHub Desktop.
def parseProductionId(string: String): Option[ProductionId] = {
val explicitRegex = "ProductionId\\((.+)\\)".r
val explicitMatch = explicitRegex.findFirstMatchIn(string).map(_.group(1)).map(ProductionId)
val implicitMatch = "([A-Z0-9]+/?)+(#[A-Z0-9]+)?".r
explicitMatch.orElse(implicitMatch.findFirstMatchIn(string).map(_.group(0)).map(ProductionId))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment