Go (RE2)

Negative Lookbehind (Decimals Without $) in GO

Go (RE2) can't run this pattern out of the box.

Try it in the GO tester →

Why it doesn't work in GO

Go's RE2 engine doesn't support lookarounds (`(?=...)`, `(?<=...)`, etc.) — they break the linear-time matching guarantee.

Workaround

Restructure to capture the surrounding context as a group instead, or use JS / Python where lookarounds are available.

Pattern

regexGO
(?<!\$)\b\d+\.\d{2}\b   (flags: g)

How the pattern 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.50

Matches

  • 1.50

Input

Discount 10.00 off $99.99

Matches

  • 10.00

Input

$5.00 only

No match

Same pattern, other engines

← Back to Negative Lookbehind (Decimals Without $) overview (all engines)