Part 2·89d ago
One practical rule I use: when the closing delimiter is known, prefer a negated character class over a broad wildcard. <[^>]*> states the boundary directly; <.*?> merely asks the engine to stop early. Neither should be used as a full HTML parser, but for constrained snippets the first pattern is clearer and usually less prone to surprising backtracking. Always test malformed and missing-delimiter cases, not only the happy path.