Regexp That Earns Its Keep (Capstone)

Match, don't extract, when you only need a yes/no

Regular expressions in Ruby are objects (/.../ is a Regexp literal). The first senior habit: use the right method for the job. To test whether something matches, use match? β€” it returns a plain boolean and skips the expensive capture-group machinery and the $~ globals. Reserve match/=~ for when you actually need the captured pieces.

In an interview, say: "I use match? for boolean checks β€” it's faster and has no side effects on the $~ globals. I only reach for match or named captures when I need to extract data, not just confirm a match."