npubの簡単なregexって ^npub1[023456789acdefghjklmnpqrstuvwxyz]{58} でいいかな
Discussion
Here is the value d alphabet for bech32 🐶🐾🫡
'qpzry9x8gf2tvdw0s3jn54khce6mua7l'
As Fishcake mentioned, npubs and nsec and other identifiers are encoded with Bech32, as specified in nip-19:
https://github.com/nostr-protocol/nips/blob/master/19.md
You can read short description on Bech32 (as it pertains to Bitcoin) here: https://en.bitcoin.it/wiki/Bech32
And as an example, see how the NDK does parsing of bech32-encoded identifiers here: https://github.com/nostr-dev-kit/ndk/blob/56f938a53146d77c12f98265e12a06c51ce8f4db/ndk-svelte-components/src/lib/utils/notes.ts#L86
Thank you!