Why “(?:\s|.)*“ is a bad pattern to match any character including line breaks

We are so fond of using a dot to match any character that we forget it does not always match line break characters. Then some of us who know about alternation think that (\s|.) or ( |.) or even (.|[ ]) will do. This is really an evil pattern causing slowdowns and stack overflow issues. Even when the capturing group is replaced with a non-capturing group. REGEX FIDDLE: FURTHER LINKS
Back to Top