k4m4 / ripple-regex

Regular expression for matching Ripple (XRP) addresses.
MIT License
7 stars 2 forks source link
cryptocurrency-regex matcher regex regex-match ripple xrp

ripple-regex Build Status XO code style

Regular expression for matching Ripple (XRP) addresses

Install

~ ❯❯❯ npm install ripple-regex

Usage

const rippleRegex = require('ripple-regex');

rippleRegex().test('nodejsrocks rG2ZJRab3EGBmpoxUyiF2guB3GoQTwMGEC');
//=> true

rippleRegex({exact: true}).test('nodejsrocks rG2ZJRab3EGBmpoxUyiF2guB3GoQTwMGEC foo');
//=> false

rippleRegex({exact: true}).test('rG2ZJRab3EGBmpoxUyiF2guB3GoQTwMGEC');
//=> true

'nodejsrocks rG2ZJRab3EGBmpoxUyiF2guB3GoQTwMGEC unicorn rfBKzgkPt9EvSJmk1uhoWTauaFCaRh4jMp rainbow'.match(rippleRegex());
//=> ['rG2ZJRab3EGBmpoxUyiF2guB3GoQTwMGEC', 'rfBKzgkPt9EvSJmk1uhoWTauaFCaRh4jMp']

API

rippleRegex([options])

Returns a regex for matching XRP addresses.

options.exact

Type: boolean
Default: false (Matches any XRP address in a string)

Only match an exact string. Useful with RegExp#test() to check if a string is an XRP address.

Related

License

MIT © Nikolaos Kamarinakis