2

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.

2
  • 2
    Why do you want this? If you've already made the assumption that the regex must always be false, what's stopping you from simply using a boolean? Commented Jul 16, 2013 at 23:56
  • probably because he wants to pass it to some (library) function calling matches(). Commented Jul 17, 2013 at 0:00

1 Answer 1

6

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.