4 ms·
This. Also, I try to: - use only those regex features that are cross-platform (cross-engine?) - avoid `\w` and similar (what is word?) and instead use explici
by amenod 5y ago
This. Also, I try to:
- use only those regex features that are cross-platform (cross-engine?)
- avoid `\w` and similar (what is word?) and instead use explicit rules (`[a-zA-Z]+`)
- use [] instead of backslashes when escaping (`[(]` instead of `\(`) - especially useful with double/triple escaping
- never use long regexes (there is always a better way)
I never understood why people are afraid of regular expressions.
That said, there are some performance/security implications wrt. backtracking that one should be aware of [0].
[0] https://javascript.info/regexp-catastrophic-backtracking https://javascript.info/regexp-catastrophic-backtracking
- fiddlerwoaroof 5y ago\w and “<“ and “>” are useful in regular expressions for programming source code because you can define them to match the character set of the programming language’s identifiers.
- valenterry 5y ago> avoid `\w` and similar (what is word?) and instead use explicit rules (`[a-zA-Z]+`) I don't think that's a good idea. What about Chinese, Japanese, Arabic, ...?