0

Just wondering if anyone can help me preg_match a Stellar public address in PHP?

1

A stellar address begins with "G", followed by "[A-D]" and then 54 characters from this base32 alphabet "[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]", so:

preg_match('/^G[ABCD]{1}[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]{54}$/', $s);

However you could also use this php sdk like this:

  try {
        $key = \ZuluCrypto\StellarSdk\Keypair::newFromPublicKey($s);
   } catch (Exception $e) {
        exit('Invalid Address: ' . $s);
   }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.