It is useful to consider three characteristics of an unknown string: Does it have the expected length, encoding and prefix?
Prefix
Common addresses formats start with 1, 3, bc1p, bc1q
Common key formats start with 5, K, L, M, xpriv, xpub
Length
Addresses starting with 1 or 3 usually have length 49
Addresses starting with bc1 usually have length around 52
Keys starting with L usually have length around 62
Encoding
Bitcoin addresses and keys are often presented in Hexadecimal, Base58Check or Bech32 encodings. These can be distinguished from one another by the range of letters and other characters present
| Encoding | Characters | Note |
|---|---|---|
| Hex | 0123456789 plus ABCDEF or abcdef |
unmixed uppercase or lowercase only |
| Base64 | 0-9 plus A-Z plus a-z plus /+ |
The presence of + is an important clue. Often used as padding at end |
| Base58Check | 123456789 plus A-N plus P-Z plus a-h plus jk plus m-z |
Never contains any of 0Oil |
| Bech32 | 0 2-9 plus b-h plus j-n plus p-z |
all lowercase omitting any of 1aio |
References:

