4 ms·
What is the purpose of the ? here?
by blodorn 4y ago
What is the purpose of the ? here?
- nfhshy68 4y agoI dunno, but I've seen a bug like this in prod while consulting.
- wiml 4y agoIt makes the preceding * less "greedy". I don't think it has any effect on the set of strings matched by this regexp, though, which is a simple string suffix check.
- jakopo87 4y agoI agree, but the dot should be escaped because it matches any character, so "@domain\.com$" should just works for.
- jasonm23 4y agoOr use [.] so it's super clear on the a-human-is-reading-it parse.
- account42 4y agoI don't think that's clearer because for [.] I need to remember that . does not need to be escaped in character classes whereas \. is quite clearly an escaped literal character without any advanced regexp knowledge.
- jasonm23 4y agoNon-greedy match (match what's necessary nothing more.) The default is greedy... match match match nom nom nom!