Reference
Regular expressions, explained
A regular expression is a small program that matches text. These entries explain the constructs that matter in daily work, how engines disagree about them, and where a pattern can become slow or wrong.
What a regex actually does
A pattern describes a set of strings. The engine walks the input, tries the pattern at each position, and returns the first match unless a global flag asks for more. Quantifiers and alternation make that search backtrack: the engine can undo a choice and try another, which is both the source of the expressive power and of the worst performance failures.
Almost every syntax question is answered by knowing three things: which engine you are using, which flags are active, and whether the pattern is anchored. Entries below name the engine when behaviour differs.
Engines are not interchangeable
JavaScript follows ECMAScript, which supports lookbehind and named groups but not possessive quantifiers or atomic groups. PCRE and Java add those. Python's re requires fixed-width lookbehind. RE2 and similar linear-time engines drop backreferences and lookaround entirely to guarantee performance.
A pattern that works in one language can fail to compile in another, or compile and mean something slightly different. Portability starts with avoiding the exotic constructs unless they are needed.