# relib

> A regular expression library for node.js

Latest version **0.2.1** (published 2015-02-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install relib
pnpm add relib
yarn add relib
bun add relib
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2015-02-23 |
| First published | 2015-01-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mark Zhan |
| Maintainers | markzhan |
| Keywords | re, regex, regexp, regular, expression, ip, url, email, domain, address, internet, protocol, string, text, is, test, find, parse, check, match, contain, pattern, validate |

## Links

- npm: https://www.npmjs.com/package/relib
- Repository: https://github.com/markzhan/relib
- Issues: https://github.com/markzhan/relib/issues
- npm.io page: https://npm.io/package/relib

## Dependencies (1)

- [recoo](https://npm.io/package/recoo.md) ^1.0.7

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 0.2.1 (latest) — 2015-02-23
- 0.2.0 — 2015-02-23
- 0.1.11 — 2015-02-09
- 0.1.10 — 2015-02-09
- 0.1.9 — 2015-02-08
- 0.1.8 — 2015-02-07
- 0.1.7-a — 2015-02-06
- 0.1.7 — 2015-02-05
- 0.1.6 — 2015-02-05
- 0.1.5 — 2015-02-05
- 0.1.3 — 2015-02-05
- 0.1.2 — 2015-02-05
- 0.1.1 — 2015-02-03
- 0.1.0 — 2015-01-27

## README

[![Build Status](https://api.travis-ci.org/markzhan/relib.svg?branch=master)](https://travis-ci.org/markzhan/relib)
[![Coverage Status](https://coveralls.io/repos/markzhan/relib/badge.svg)](https://coveralls.io/r/markzhan/relib)
[![NPM Downloads](https://img.shields.io/npm/dm/relib.svg?style=flat)](https://www.npmjs.org/package/relib)


# relib

A regular expression library for node.js.


## Installation

```sh
$ npm i relib --save
```

## Usage

```js
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](#recoo)
- [IP Address Regex](#ip)
- [Email Address Regex](#email)
- [Domain Regex with IDN Support](#domain)
- [URLs Regex](#url)
...

<a name='recoo'></a>
### 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](https://github.com/markzhan/recoo/blob/master/README.md) for details.

<a name='ip'></a>
### 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

```js
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
```

<a name='email'></a>
### 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.

```js
var email = require('relib').email;

email.is('markzhann@gmail.com'); // true
email.contain('unicorn markzhann@gmail.com'); // true
email.match('unicorn markzhann@gmail.com cake john@doe.com rainbow'); // ['sindresorhus@gmail.com', 'john@doe.com']
```

<a name='domain'></a>
### 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.

```js
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']
```

<a name='url'></a>
### 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.

```js
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:
```sh
npm i && npm test  # install dev dependencies and test
```
For bugs and feature requests, [please create an issue](https://github.com/markzhan/relib/issues).

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](https://github.com/markzhan/relib/graphs/contributors)


## License

MIT © 2015 [Mark Zhan](http://markzhan.com).

---
_Source: https://npm.io/package/relib · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
