Merge these patterns into a single one.  Use a nested, anonymous group and a ? qualifier to make multiline matching optional.