RegEx to match Bitcoin addresses?

前端 未结 8 2254
深忆病人
深忆病人 2020-12-14 06:44

I am trying to come up with a regular expression to match Bitcoin addresses according to these specs:

A Bitcoin address, or simply address, is an iden

8条回答
  •  无人及你
    2020-12-14 07:19

    Based on the description here: https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki I would say the regex for a Bech32 bitcoin address for Version 1 and Version 0 (only for mainnet) is:

    \bbc(0([ac-hj-np-z02-9]{39}|[ac-hj-np-z02-9]{59})|1[ac-hj-np-z02-9]{8,87})\b

    Here are some other links where I found infos:

    • https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki
    • http://r6.ca/blog/20180106T164028Z.html

提交回复
热议问题