The refined library allows to define refinement that matches a given regex
, as shown in the Readme
:
import eu.timepit.refined._
import eu.timepit.refined.string._
import eu.timepit.refined.api.Refined
type MyType = String Refined MatchesRegex[W.`"[0-9]+"`.T]
While this works perfectly fine, we can't define this way a type that matches a regex containing a backtick, because as describe here there is no way to escape a backtick within a literal
:
type MyType = String Refined MatchesRegex[W.`"(a|`)"`.T]
// Getting a compile-error:
// ']' expected but ')' found.
So would there be a way to define such a type (i.e MatchesRegex
with a regex containing a backtick)?