Writing Regex in Scala Parser Combinators

When trying to write a regex of the form :
"""[A-Z]_[a-zA-Z]+""".r

The IDE outputs a red underline under the .r keyword.

Could you possibly explain what might be the problem please?

Thanks a lot and good day :slight_smile:

Which Scala version and which IDE are you using?

BTW, the .r is not a keyword, it’s just a normal (extension) method on String. See StringOps

1 Like

Thanks for your help.

My Scala version is 2.13.4 and I am using the IntelliJ IDE.

Thanks a lot and good day :slight_smile:

Did you tried compiling the code with a real compiler, like a build tool (e.g. sbt)?

If no, try it and see, it should just compile; IntelliJ has fame of producing false warnings.
If it doesn’t, then it may help to include the full error as well as the surrounding code here.

Thanks for your help.

Is there any particular IDE which you would prefer please ?

Thanks a lot and good day :slight_smile:

I personally like to use metals with vscode.

The good things are: it is fast and produces correct diagnostics since it is using a real compiler under the hood, also since I use it together with sbt as the bsp then the compilation is shared which is great.

The bad things are:

  • Its getting started experience is more complex than the one of IntelliJ (especially if you are also new to the language and do not know yet what sbt is).
  • Not sure how well it works on Windows, this doesn’t affect me since I am using WSL 2 but still this may be a problem for some people.
  • Smaller feature set compared with IntelliJ.
1 Like

Most people I know use IntelliJ IDEA. The false errors can be annoying, but usually they are no big deal.

1 Like

PĂĄ torsdag 28. januar 2021 kl. 14:43:23, skrev Gianluca via Scala Users <[email protected]>:

| gzah
January 28 |

  • | - |

Thanks for your help.

Is there any particular IDE which you would prefer please ?

Thanks a lot and good day :slight_smile:

Note that IntelliJ also uses a “real compiler” when compiling. It’s when IntelliJ IDEA is performing code-inspection (highlighting etc) that it sometimes misses, but IMO the benefits of IntelliJ far outwieghts this.

1 Like