Why the same regex behaves differently in different languages
Engines like PCRE, JavaScript's RegExp, and Python's re share most core syntax but differ in details — whether \d matches only ASCII digits, or whether lookbehind is supported — so a pattern tested in one place is not guaranteed to work identically elsewhere.
Regex is good at pattern matching, not full parsing
For genuinely structured formats like HTML or JSON, regex tends to become fragile and hard to maintain past a certain complexity. It excels at flat, line-oriented validation and extraction, like matching an email shape or pulling digits out of a string.
Frequently Asked Questions
Why does my pattern match more text than I expected?
Usually a greedy quantifier grabbing more than intended — try a lazy version (*? or +?) or narrow the character class instead of using a broad wildcard.
What is the difference between a capture group and a non-capturing group?
A capture group (pattern) saves its matched text so you can reference it later, such as in a replacement string. A non-capturing group (?:pattern) only affects how the pattern groups and applies quantifiers, without saving anything.