Text Processingflags: g
Negative Lookbehind (Decimals Without $)
Use negative lookbehind `(?<!...)` to match decimal numbers NOT preceded by a dollar sign.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
(?<!\$)\b\d+\.\d{2}\b (flags: g)Raw source: (?<!\$)\b\d+\.\d{2}\b
How it works
(?<!\$) is a zero-width assertion that succeeds only when the position is NOT preceded by `$`. \b\d+\.\d{2}\b then matches a decimal with exactly two fractional digits. JS and Python both support negative lookbehind; Go's RE2 does NOT support any lookbehind at all.
Examples
Input
Price $19.99 vs ratio 1.50Matches
1.50
Input
Discount 10.00 off $99.99Matches
10.00
Input
$5.00 onlyNo match
—Common use cases
- •Extracting non-currency decimals from financial text
- •Linting rules that ignore certain prefixes
- •Filtering URL paths that don't begin with a marker
- •Selective text replacement avoiding marked tokens
Related patterns
Negative Lookahead
Text ProcessingUse negative lookahead `(?!...)` to match words that are NOT in a blocklist (here: log-level keywords).
JSON Key-Value Pair (Simple)
Text ProcessingExtract simple `"key": value` pairs from JSON-ish text (strings, numbers, booleans, null).
JSON Number (Strict)
Text ProcessingMatch JSON-spec numbers — disallows leading zeros (no `01`), allows decimals and exponents.
Non-Capturing Group (Image URL)
Text ProcessingUse non-capturing groups `(?:...)` to alternate without polluting the captured-groups list.