npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

relib

v0.2.1

Published

A regular expression library for node.js

Downloads

130

Readme

Build Status Coverage Status NPM Downloads

relib

A regular expression library for node.js.

Installation

$ npm i relib --save

Usage

var ips = require('relib').ip
,v4 = ips.v4 ,v6 = ips.v6 ,ip = ips.ip;

console.log(v4.is('192.168.0.1')); // true
console.log(v6.is('1:2:3:4:5:6:7:8')); // true
console.log(ip.is('1:2:3:4:5:6:7:8')); // true
console.log(ip.contain('abc 192.168.0.1')); // true
console.log(ip.match('abc 1:2:3:4:5:6:7:8')); // ['1:2:3:4:5:6:7:8']

console.log(ip.e('unicorn 192.168.0.1').is()); // false
console.log(ip.e('unicorn 192.168.0.1').contain());  // true
console.log(ip.e('unicorn 192.168.0.1').match());  // [ '192.168.0.1' ]
console.log(ip.e().test('unicorn 192.168.0.1')); // = .contain() -> true
console.log(ip.exact().e().test('unicorn 192.168.0.1')); // = .is() -> fasle
console.log(v6.e()); // /(?:(?:[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 = require('relib').ip
,v4 = ips.v4 ,v6 = ips.v6 ,ip = ips.ip;

ip.is('1:2:3:4:5:6:7:8'); // true
ip.is('unicorn 192.168.0.1'); // false
ip.contain('unicorn 192.168.0.1 cake 1:2:3:4:5:6:7:8 rainbow'); // true
ip.match('unicorn 192.168.0.1 cake 1:2:3:4:5:6:7:8 rainbow'); // ['192.168.0.1', '1:2:3:4:5:6:7:8']

v4.is('192.168.0.1'); // true
v4.is('1:2:3:4:5:6:7:8'); // false
v6.is('1:2:3:4:5:6:7:8'); // 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 = require('relib').email;

email.is('[email protected]'); // true
email.contain('unicorn [email protected]'); // true
email.match('unicorn [email protected] cake [email protected] rainbow'); // ['[email protected]', '[email protected]']

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 = require('relib').domain;

domain.is('example.com'); // true
domain.is('unicorn example.com'); // false
domain.contain('unicorn example.com cake a.sub.domain.org rainbow'); // true
domain.match('unicorn example.com cake a.sub.domain.org rainbow'); // ['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 = require('relib').url;

url.is('https://github.com'); // true
url.contain('foo github.com bar google.com'); // true
url.match('foo https://github.com bar google.com'); // ['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.

  1. Fork it
  2. Create your feature branch git checkout -b my-new-feature
  3. Commit your changes git commit -am 'Add some feature'
  4. Push to the branch git push origin my-new-feature
  5. Create new Pull Request

Contributors

License

MIT © 2015 Mark Zhan.