<p>A regex itself isn't capable of validating if an address is valid or not. You need to have a little more logic. Probably what you're looking for is something like from_bytes/from_bech32/from_base58 utilized in this library: <a href="https://github.com/Emurgo/cardano-serialization-lib/blob/master/rust/src/address.rs" rel="nofollow noreferrer">https://github.com/Emurgo/cardano-serialization-lib/blob/master/rust/src/address.rs</a></p>
<p>If you really need it to just be a regex, shelley addresses are pretty easy to validate in bech32 format, it's <code>addr1[a-z0-9]+</code> and byron addresses are base58 encoded <code>[1-9A-HJ-NP-Za-km-z]+</code>. But neither of these ensure the address is accepted by the blockchain, it just loosely restricts the character set accepted.</p>

CC BY-SA 4.0
2022-08-08T16:44:15.737Z
Is something like this available in golang?
Barney Chambers
CC BY-SA 4.0
2021-10-04T16:20:56.167Z
2021-10-04T16:20:56.167Z
Samuel Leathers
<p>Can anyone help me in creating a regular expression to preg_match (php) all of Cardano's public wallet address formats?</p>

CC BY-SA 4.0
2021-08-19T05:21:06.883Z
What have you tried so far? Can you share your progress? And could you give some examples of the different address formats you try to match with your regex?
eddex
CC BY-SA 4.0
2021-08-19T06:57:28.097Z
Well i know there are 2 address types. The Byron which start with Ae2 and DdzFF. The second address and more recent type starts with addr1. Not sure of the min and max length of these addresses. Can't find much about it.
Bitcoin Expert
<ada><cardano-address>
How would I create a regular expression to match all of Cardano's public wallet address formats?
# How would I create a regular expression to match all of Cardano's public wallet address formats?

(Asked by: username_0 on 2021-08-18)

Can anyone help me in creating a regular expression to preg\_match (php) all of Cardano's public wallet address formats?

**Tags:** ada, cardano-address
> **Comments:**
> **username_1**: What have you tried so far? Can you share your progress? And could you give some examples of the different address formats you try to match with your regex?  
> **username_0**: Well i know there are 2 address types. The Byron which start with Ae2 and DdzFF. The second address and more recent type starts with addr1. Not sure of the min and max length of these addresses. Can't find much about it.  

---

## 1 answers

### Answer by username_2 on 2021-10-04. Score: 2

A regex itself isn't capable of validating if an address is valid or not. You need to have a little more logic. Probably what you're looking for is something like from\_bytes/from\_bech32/from\_base58 utilized in this library: <https://github.com/Emurgo/cardano-serialization-lib/blob/master/rust/src/address.rs>

If you really need it to just be a regex, shelley addresses are pretty easy to validate in bech32 format, it's `addr1[a-z0-9]+` and byron addresses are base58 encoded `[1-9A-HJ-NP-Za-km-z]+`. But neither of these ensure the address is accepted by the blockchain, it just loosely restricts the character set accepted.

> **Comments:**
> **username_3**: Is something like this available in golang?  

---

