0

As the title says I cannot match the "<" character in Java 8 regular expressions.

The following expressions all evaluate to false:

"<hello>".matches("<")

"<hello>".matches(Pattern.quote("<"))

"<hello>".matches("\\<")

"<hello>".matches(Pattern.quote("\\<"))

How can I escape angular brackets in regular expressions in Java 8?

xgb84j
  • 519
  • 2
  • 8
  • 19

1 Answers1

1
"<hello>".matches("<.*");// => true

You need to match wathever comes after => use .*

pdem
  • 3,880
  • 1
  • 24
  • 38