For people that want to do a simple verification of a Monero address to ensure it has been entered correctly, what are some methods that can be employed?

- 4,566
- 4
- 31
- 57

- 6,494
- 2
- 19
- 47
5 Answers
Here is a simple regular expression and javascript code snippet that can be used to confirm a Monero address has been entered correctly.
Regular expression:
4[0-9AB][<insert-all-base-58-characters-here>]{93}
In Javascript:
addr_str.match(/4[0-9AB][123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{93}/);
Credit goes to /u/binaryfate for the useful info.

- 6,494
- 2
- 19
- 47
-
2It is also worth noting that this doesn't ensure that there are no typos (can't really check checksum with regular expressions), and that it's suitable only for regular addresses – JollyMort Sep 13 '16 at 18:00
-
3To ferretinjapan, you might want to look at the code for steps 8 to 15 here. Might be beneficial to this question or for a new question. – dEBRUYNE Sep 13 '16 at 18:49
-
1If you go on https://moneroaddress.org and type in both
41a
and41z
, you'll notice it says "INVALID PREFIX" for41a
(but not for41z
), while thea
character is part of Base58. Therefore, I think the regular expression posted is still a simplification. – dpzz Oct 08 '16 at 13:40 -
@dpzz According to JS code,
lowest_address
= "41d7FXjswpK1111111111111111111111111111111111111111111111111111111111111111111111111111112KhNi4" andhighest_address
= "4BKnGLZNZ5pjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQVmzCh57" I have no idea if that is technically correct. – Jonathan Cross Sep 20 '17 at 00:54 -
Should have a
^
at the front since the address must start with a4
i.e..match(/^4...
– nu everest Nov 06 '17 at 02:15 -
@dpzz – That site is incorrect. Lowercase
z
is indeed one of the constituent characters of base58. Monero's base58 implementation clearly says it's base64 minusIO10+/
, just like Bitcoin's implementation. – Adam Katz Nov 28 '22 at 17:17
This is better:
4[a-zA-Z|\d]{94}
And payment ID:
[0-9a-fA-F]{64}

- 551
- 4
- 12
-
1
-
The Payment ID is supposed to be hex, but can be 16 or 64 chars. The address regex is very loose and includes invalid characters plus a nonsense pipe character. Better see the selected answer as this one has big problems. – Jonathan Cross Sep 20 '17 at 01:04
There are some inappropriate regexes to the other answers here. At this time, only ferretinjapan's answer is correct, though it's a mouthful since it does not use ranges.
This regex will match (non-integrated) Monero addresses (subaddresses start with 8
):
^[48][0-9AB][1-9A-HJ-NP-Za-km-z]{93}$
An integrated address has 106 or 136 characters and that the second character may be any base58 character (verification needed; this is a result of changing the netbyte prefix). Here's a regex to match just integrated (either 64-bit or full 256-bit) addresses:
^4[1-9A-HJ-NP-Za-km-z]{105}(?:[1-9A-HJ-NP-Za-km-z]{30})?$
To match any Monero address (standard, subaddress, integrated, or full 256-bit integrated):
^(?:[48][0-9AB]|4[1-9A-HJ-NP-Za-km-z]{12}(?:[1-9A-HJ-NP-Za-km-z]{30})?)[1-9A-HJ-NP-Za-km-z]{93}$
With any of these regexes, if you are extracting addresses from larger bodies of text, you likely want to replace the ^
and $
anchors with \b
word boundary markers.

- 111
- 4
My Java Example:
public static boolean MoneroValid(String addr) { String regex = "^4[0-9AB][1-9A-HJ-NP-Za-km-z]{93}$"; return addr.matches(regex); }

- 19,111
- 4
- 14
- 51
-
This doesn't catch integrated addresses, stagenet or testnet addresses. – jtgrassie Aug 14 '19 at 01:08
Long time ago someone pointed to me this regex to address
/4([0-9]|[A-B])(.){93}/
I belive its an more complete one, I am using it on PHP-Monero

- 635
- 3
- 7
-
1This is not an accurate regex. The
.
(dot) matches any character. – Jonathan Cross Sep 20 '17 at 00:32
addrCheck()
function here: https://xmr.llcoins.net/js/site.js – nu everest Nov 06 '17 at 02:56