Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Non-capturing group not working #383

Open
@hissashirocha

Description

@hissashirocha

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 only003:

val cycle = """(?:CLEARING\sCYCLE\s)([0-9]{3})""".r"CLEARING CYCLE 003" match {  case cycle(a) => println(a)}

But when I try usingRegexParsers, I get the whole stringCLEARING CYCLE 003 instead of just the numbers:

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp