omega
omega

Reputation: 43843

How to force fail a java regex?

In java, you can text a regex by doing

"mystring".matches("myregex")

But is there a certain regex you can use, that will make matches function evaluate to a false? It needs to work for all cases (i.e. no matter what string you test it with).

Thanks.

Upvotes: 2

Views: 177

Answers (1)

Jon McPherson
Jon McPherson

Reputation: 2535

I don't know why you would need this, but this should do the trick

"mystring".matches("(?!)")

Upvotes: 6

Related Questions