Use the "dot matches newline" switch:
if (str.matches("(?s)<Element>\\s*<Sub>(.*)"))
With the switch turned on, \s
will match newline characters.
I slso fixed your regex, removing two sets of redundant brackets, and adding the crucial *
after the whitespace regex.