We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm testing Scala Parser Combinators but for some reason I can't make non-capturing group work.
When I run the following, it works the way I want, returning only 003:
003
val cycle = """(?:CLEARING\sCYCLE\s)([0-9]{3})""".r "CLEARING CYCLE 003" match { case cycle(a) => println(a) }
But when I try using RegexParsers, I get the whole string CLEARING CYCLE 003 instead of just the numbers:
RegexParsers
CLEARING CYCLE 003
class TestParser extends RegexParsers { def cycle: Parser[String] = """(?:CLEARING\sCYCLE\s)([0-9]{3})""".r } object Test extends TestParser { def parse(text: String) { parse(cycle, text) match { case Success(matched,_) => println(matched) case Failure(msg,_) => println(s"FAILURE: $msg") case Error(msg,_) => println(s"ERROR: $msg") } } } Test.parse("CLEARING CYCLE 003")
Am I missing something or is it an issue?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I'm testing Scala Parser Combinators but for some reason I can't make non-capturing group work.
When I run the following, it works the way I want, returning only
003
:But when I try using
RegexParsers
, I get the whole stringCLEARING CYCLE 003
instead of just the numbers:Am I missing something or is it an issue?
The text was updated successfully, but these errors were encountered: