Qaynaq LABS · TOOLS

REGEX · JAVASCRIPT

Regex explained

^[a-zA-Z0-9+/]{43}=$

Matches a string that is exactly 44 characters long, where the first 43 characters are alphanumeric, plus, or slash, and the last character is an equals sign.

Token-by-token breakdown

TokenMeaningExample
^ Anchor: asserts position at start of the string Start of string
[ Start of a character class N/A
a-z Character class: lowercase letters a through z a, b, ..., z
A-Z Character class: uppercase letters A through Z A, B, ..., Z
0-9 Character class: digits 0 through 9 0, 1, ..., 9
+ Literal plus sign +
/ Literal forward slash /
] End of character class N/A
{43} Quantifier: exactly 43 occurrences of the preceding element (the character class) 43 repetitions of [a-zA-Z0-9+/]
= Literal equals sign =
$ Anchor: asserts position at end of the string End of string

Matches

  • AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
  • abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/=
  • 123456789012345678901234567890123456789012=
  • aB3+/aB3+/aB3+/aB3+/aB3+/aB3+/a=
  • Zz9+/Zz9+/Zz9+/Zz9+/Zz9+/Zz9+/Z=
  • QWxhZGRpbjpvcGVuIHNlc2FtZQ==

Does not match

  • AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  • AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
  • AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  • AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
  • AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
  • aB3+/aB3+/aB3+/aB3+/aB3+/aB3+/a=
  • QWxhZGRpbjpvcGVuIHNlc2FtZQ=
  • QWxhZGRpbjpvcGVuIHNlc2FtZQ===

Common pitfalls

  • Forgetting that the string must be exactly 44 characters long (43 + 1 for '=').
  • Assuming the character class includes other characters like underscores or hyphens.
  • Not accounting for case sensitivity in the alphanumeric characters.
  • Overlooking that the equals sign is a literal and not part of the character class.

Performance notes

No catastrophic backtracking risk due to fixed quantifier {43} and no nested quantifiers. The pattern is efficient for strings of this fixed length. Ensure input strings are not excessively long to avoid unnecessary processing.

About regular expressions

Regular expressions are tiny programs that match patterns in text. They're powerful and notoriously cryptic — most engineers can write them but few can read them confidently. Qaynaq Labs' regex explainer breaks any pattern into its constituent tokens, shows what each one does, and runs through both matching and non-matching examples so you can verify the logic.

Different regex flavors (JavaScript, PCRE, Python, Go) have subtle differences in syntax and supported features. Pick your flavor in the input — the explainer accounts for it.

Frequently asked

Why is the pattern exactly 44 characters long?

The pattern requires exactly 43 characters from the character class [a-zA-Z0-9+/] followed by a single equals sign, totaling 44 characters.

Does this pattern match Base64 encoded strings?

Yes, this pattern matches a subset of Base64 encoded strings that are exactly 44 characters long, ending with an equals sign. Base64 typically uses padding with '=' at the end.

Can the equals sign appear anywhere else in the string?

No, the equals sign must be the last character due to the $ anchor. It cannot appear earlier in the string.

Is this pattern case-sensitive?

Yes, the character class [a-zA-Z0-9+/] explicitly includes both lowercase and uppercase letters, making it case-sensitive.