H
H
HakerHelp2016-09-14 17:29:02
JavaScript
HakerHelp, 2016-09-14 17:29:02

How to parse a Bitcoin address using JavaScript?

Hello, I need to parse a bitcoin address.
Here is an example: https://jsfiddle.net/congrammer/Ej25j/2371/
The task is to parse only what is in any tags, i.e.:

<small>адрес</small>
<div>адрес</div>
<h1>адрес</h1>
и.т.д

So it seems to work, but it parses a lot of superfluous.
var re = new RegExp("([a-zA-Zа-я0-9]{27,34})", "g"); 
alert(document.body.innerHTML.match(re))

I can't work with regular expressions at all))

Answer the question

In order to leave comments, you need to log in

3 answer(s)
H
HakerHelp, 2016-09-14
@HakerHelp

If you want to do something, do it yourself!

var re = new RegExp("[^/\"//\'/a-zA-Z0-9]([1|3][^IlO0][a-zA-Z1-9]{26,34})", "g"); 
document.body.innerHTML.match(re)

V
Vladimir Martyanov, 2016-09-14
@vilgeforce

https://en.bitcoin.it/wiki/Technical_background_of... read until you are fully enlightened, Comrade Hacker.

W
waspr, 2020-12-17
@waspr

Bitcoin address regular (P2PKH, P2SH, Bech32)

^(bc(0([ac-hj-np-z02-9]{39}|[ac-hj-np-z02-9]{59})|1[ac-hj-np-z02-9]{8,87})|[13][a-km-zA-HJ-NP-Z1-9]{25,35})$

Filters everything that looks like a bitcoin address, but this does not guarantee that the address is valid. regular checksum and some other address parameters are not checked.
More about addresses:
https://github.com/bitcoin/bips/blob/master/bip-01...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question