1

I'm having html page content as a string and trying to check if it matches regexp of ^.+$. And it returns false. Can't get why it does so.

Code is fairly simple:

content.matches(regexp)
Denys S.
  • 6,358
  • 12
  • 43
  • 65
  • 1
    Please show the exact code that is being used, in addition an example of the HTML that isn't matching. – vcsjones Jul 14 '11 at 17:34
  • 1
    @vcsjones, there's no need to post input: if `^.+$` doesn't match, it's either an empty string, or it contains a `\r` or `\n`. In all other cases, the regex would match (`matches("^.+$")` would return `true`). – Bart Kiers Jul 14 '11 at 17:44

1 Answers1

3

By default, the . does not match \r and \n. To let . also match them, enable DOT-ALL (the s flag):

^(?s).+$
Bart Kiers
  • 166,582
  • 36
  • 299
  • 288