Devious regexp trick I've not seen before: [^] Negating the empty set matches any character, which lets you emulate DOTALL (i.e. a . matches newlines too) on older regexp implementations. https://stackoverflow.com/a/47317639/509706