Skip to content

Pattern.compile doesn't validate regex #1718

@japgolly

Description

@japgolly

In Java/Scala, Pattern.compile fails immediately on invalid regex.
In ScalaJS, it isn't until the pattern is used that it fails.

// Doesn't throw in ScalaJS
val p = Pattern.compile("*")

To mimic JVM behaviour here (because I need to validate user-entered regex immediately), I just do this as a workaround:

// Throws an exception
p.matcher("").matches()

Metadata

Metadata

Assignees

Labels

bugConfirmed bug. Needs to be fixed.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions