Go (RE2)

Positive Lookahead (Password) 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
^(?=.*\d)(?=.*[A-Z])[A-Za-z\d]{8,}$

How the pattern works

(?=.*\d) is a zero-width assertion that requires the rest of the string to contain a digit somewhere. (?=.*[A-Z]) similarly requires an uppercase letter. Neither consumes characters. [A-Za-z\d]{8,}$ then matches the actual password content (≥8 alphanumerics). Lookaheads are supported in JS and Python; Go's RE2 does NOT support them.

Examples

Input

Password1

Matches

  • Password1

Input

weakpass

No match

Input

ALLCAPSNODIGIT

No match

Same pattern, other engines

← Back to Positive Lookahead (Password) overview (all engines)