Skip to content

Instantly share code, notes, and snippets.

@ctcarrier
Created January 8, 2014 17:04
Show Gist options
  • Save ctcarrier/8320276 to your computer and use it in GitHub Desktop.
Save ctcarrier/8320276 to your computer and use it in GitHub Desktop.
trait BlPathMatchers {
val BSONObjectID: PathMatcher1[BSONObjectID] =
PathMatcher("""[\da-fA-F]""".r) flatMap { string ⇒
try Some(new BSONObjectID(string))
catch { case _: IllegalArgumentException ⇒ None }
}
}
@ymeymann
Copy link

ymeymann commented Aug 6, 2015

The expression should be [\da-fA-F]* otherwise it matches only the first character

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment