With REG_NEWLINE, POSIX says: "A in string shall not be matched by a period outside a bracket expression or by any form of a non-matching list" musl currently matches newlines with negated brackets, even if REG_NEWLINE is used. Attached patch fixes the issue, although I'm not sure if it's the best way to do it. Also see similar glibc bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3957