I have a regex for matching public keys for the standard bitcoin public key, but it doesn't match testnet public key addresses. Does anyone have one that matches both?
Public Key Match for prod:
/^[13n][1-9A-Za-z][^OIl]{20,40}/
There appears to be a bug in your regex.
When I test it against the following:
1O!@#$%^&*()-=_+[]{};':",./<>?`~
It claims that it is a match.
Perhaps consider something like the following to match mainnet addresses instead:
/^[13][1-9A-HJ-NP-Za-km-z]{26,35}/
If you want to find testnet addresses you could try:
/^[2mn][1-9A-HJ-NP-Za-km-z]{26,35}/
If you want to match both testnet AND bitcoin addresses, you could try:
/^[123mn][1-9A-HJ-NP-Za-km-z]{26,35}/
Note that these REGEX that I've supplied should match all the addresses indicated, but they will also match some strings that are NOT valid addresses. If you really want to be certain that you are finding actual addresses, you'll need to verify the checksum.