9 ms·
Coming from a Perl background I do love regex but this is just the wrong use for it. 1. Those expressions fall down on a number of edge cases (eg heredocs / st
by hnlmorg 6y ago
Coming from a Perl background I do love regex but this is just the wrong use for it.
1. Those expressions fall down on a number of edge cases (eg heredocs / string literals)
2. It is actually perfectly reasonable to have non-ASCII inside source code because these days it's increasingly common for compilers to assume source it UTF8 and, frankly, English isn't the first language for most of the speaking world so it's rude of us to assume all comments and quoted strings should be in English.
3. There's already multiple code formatters for nearly every language out there and they take tokenised versions of your source (ie will take into account stuff like the string literals I mentioned earlier). You're far better off picking whatever code formatter is considered (de facto) standard for your language and using that. They come with the additional benefit that they don't just highlight formatting faux pas but they can also enforce style guidelines.