Post
Topic
Board Bitcoin Discussion
Re: Losing Critical Mass and Call to Action
by
theymos
on 13/09/2010, 06:50:20 UTC
Hummm, well, I didn't have any luck finding how to determine what constitutes as an address examining the c++ code, but here's a PHP function that should work as expected:

Code:
function is_bitcoin_address($address) { return preg_match("/1[a-zA-Z0-9]{33}/", $address); }
if (is_bitcoin_address("17NdbrSGoUotzeGCcMMCqnFkEvLymoou9j")) echo "yes";
else echo "no";
?>

Bitcoin excludes a few normal characters for the sake of readability, and a Bitcoin address can be either 33 or 34 characters long. It's:
1[1-9A-HJ-NP-Za-km-z]{32,33}