relib
A regular expression library for node.js.
Installation
$ npm i relib --save
Usage
var ips = ipv4 = ipsv4 v6 = ipsv6 ip = ipsip; console; // trueconsole; // trueconsole; // trueconsole; // trueconsole; // ['1:2:3:4:5:6:7:8'] console; // falseconsole; // trueconsole; // [ '192.168.0.1' ]console; // = .contain() -> trueconsole; // = .is() -> fasleconsole; // /(?:(?:[0-9a-fA-F:]){1,4}(?:(?::(?:[0-9a-fA-F]){1,4}|:)){2,7})+/
API
RECOO API
.is(String)
Check if a string is match the regex.
.contain(String)
Check if a string matching the regex.
.match(String)
Return an array if a string matching the regex.
See RECOO for details.
IP Address Regex
- .v4.is(), v4.contain(), v4.match() - IPv4 regex
- .v6.is(), v6.contain(), v6.match() - IPv6 regex
- .ip.is(), ip.contain(), ip.match() - IPv4 or IPv6
var ips = ipv4 = ipsv4 v6 = ipsv6 ip = ipsip; ip; // trueip; // falseip; // trueip; // ['192.168.0.1', '1:2:3:4:5:6:7:8'] v4; // truev4; // falsev6; // true
Email Address Regex
- email.is(string) - Check if a string is email address.
- email.contain(string) - Check if a string contains email address.
- email.match(string) - Return an array if a string contains email address.
var email = email; email; // trueemail; // trueemail; // ['sindresorhus@gmail.com', 'john@doe.com']
Domain Regex
- domain.is(string) - Check if a string is domain.
- domain.contain(string) - Check if a string contains domain.
- domain.match(string) - Return an array if a string contains domain.
var domain = domain; domain; // truedomain; // falsedomain; // truedomain; // ['example.com', 'a.sub.domain.org']
URLs Regex
- url.is(string) - Check if a string is URL.
- url.contain(string) - Check if a string contains URL.
- url.match(string) - Return an array if a string contains URL.
var url = url; url; // trueurl; // trueurl; // ['https://github.com', 'google.com']
...
Contributions
To run the tests for relib simply run:
npm i && npm test # install dev dependencies and test
For bugs and feature requests, please create an issue.
Pull requests is always welcome.
- Fork it
- Create your feature branch
git checkout -b my-new-feature
- Commit your changes
git commit -am 'Add some feature'
- Push to the branch
git push origin my-new-feature
- Create new Pull Request
License
MIT © 2015 Mark Zhan.