Token-by-token breakdown
| Token | Meaning | Example |
|---|---|---|
^ |
Anchor: asserts position at start of the string | Start of string |
[A-Za-z0-9+/] |
Character class: matches any uppercase letter, lowercase letter, digit, '+', or '/' | A, z, 5, +, / |
{86} |
Quantifier: exactly 86 occurrences of the preceding character class | 86 characters from the class |
= |
Literal character: matches the '=' character | = |
{0,2} |
Quantifier: between 0 and 2 occurrences of the preceding '=' | 0, 1, or 2 '=' characters |
$ |
Anchor: asserts position at end of the string | End of string |
Matches
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/==ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
Does not match
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789/===ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789/=AABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789/+A
Common pitfalls
- Assuming the pattern matches Base64 strings of any length (it strictly requires 86 characters before padding).
- Forgetting that the padding '=' characters must appear only at the end of the string.
- Confusing this with standard Base64 which may have different padding rules or character sets.
Performance notes
The pattern is efficient as it uses fixed quantifiers and a simple character class. No catastrophic backtracking risk due to the absence of nested quantifiers or alternations.