title: Using regex in StandardTokenParsers
body: <p>I'm trying to use regex in my StandardTokenParsers based parser. For that, I've subclassed StdLexical as follows:</p>
  
  <pre><code>class CustomLexical extends StdLexical{
    def regex(r: Regex): Parser[String] = new Parser[String] {
      def apply(in:Input) = r.findPrefixMatchOf(in.source.subSequence(in.offset, in.source.length)) match {
        case Some(matched) =&gt; Success(in.source.subSequence(in.offset, in.offset + matched.end).toString,
          in.drop(matched.end))
        case None =&gt; Failure("string matching regex `" + r + "' expected but " + in.first + " found", in)
      }
    }
  
    override def token: Parser[Token] =
      (   regex("[a-zA-Z]:\\\\[\\w\\\\?]* | /[\\w/]*".r)     ^^ { StringLit(_) }
        | identChar ~ rep( identChar | digit )               ^^ { case first ~ rest =&gt; processIdent(first :: rest mkString "") }
        | ...
  </code></pre>
  
  <p>But I'm a little confused on how I would define a Parser that takes advantage of this. I have a parser defined as:</p>
  
  <pre><code>def mTargetFolder: Parser[String] = "TargetFolder" ~&gt; "=" ~&gt; mFilePath
  </code></pre>
  
  <p>which should be used to identify valid file paths. I tried then:</p>
  
  <pre><code>def mFilePath: Parser[String] = "[a-zA-Z]:\\\\[\\w\\\\?]* | /[\\w/]*".r
  </code></pre>
  
  <p>But this is obviously not right. I get an error:</p>
  
  <pre><code>scala: type mismatch;
   found   : scala.util.matching.Regex
   required: McfpDSL.this.Parser[String]
      def mFilePath: Parser[String] = "[a-zA-Z]:\\\\[\\w\\\\?]* | /[\\w/]*".r
                                                                            ^
  </code></pre>
  
  <p>What is the proper way of using the extension made on my StdLexical subclass?</p>