on-internet
← Community

Regex Non-Capturing Groups ins Scala

Stack Overflow ·

I want to use Regex non-capturing groups in scala, briefly worded "?:". After hours of testing various cases I came here to search for a solution. I found this question and its answer, but it didn't worked for me. Is it possible to make non-capturing groups work in scala regexes when pattern matching So I wrote a minimal example to test the statement of the thread above. val test = ("""(?:<.*>)(.*)(?:<.*>)""".r findFirstIn ("<test>hello</test>")) getOrElse "" println("DEBUG MESSAGE (test): " + test) Expected Output: hello Real Output: <test>hello</test> So what is wrong with my code?

Comments

Sign in or sign up to comment and upvote.

No comments yet.