"); response.matches...">

Substitution found, but regex fails

Suppose I have a string and run the following tests:

response.indexOf("</p:panelGrid>");
response.matches(".*</p:panelGrid>.*");

How is it possible that it indexOffinds a substring (it does not return -1), but the regular expression in the second test does not match ?

I ran into this problem when trying to write a test that checks if taglib is displayed correctly in JSF using Pax Web. I could not reproduce this behavior outside of this test.

+5
source share
1 answer

.matches all but newline characters. You must change the regex string to

"(?s).*</p:panelGrid>.*"

Then it will always match.

+7
source

All Articles