Why is:
[\s\S]+?
Much more efficient than:
(?:.|\n)+?
What are the differences between the two in terms of how they work behind the scenes?
Note: this is with DOTALL
turned off. Also, from https://www.regular-expressions.info/dot.html:
JavaScript and VBScript do not have an option to make the dot match line break characters. In those languages, you can use a character class such as
[\s\S]
to match any character. This character matches a character that is either a whitespace character (including line break characters), or a character that is not a whitespace character. Since all characters are either whitespace or non-whitespace, this character class matches any character.