source: trip-planner-front/node_modules/ip-regex/readme.md@ eed0bf8

Last change on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1# ip-regex [![Build Status](https://travis-ci.org/sindresorhus/ip-regex.svg?branch=master)](https://travis-ci.org/sindresorhus/ip-regex)
2
3> Regular expression for matching IP addresses
4
5
6## Install
7
8```
9$ npm install --save ip-regex
10```
11
12
13## Usage
14
15```js
16const ipRegex = require('ip-regex');
17
18// Contains an IP address?
19ipRegex().test('unicorn 192.168.0.1');
20//=> true
21
22// Is an IP address?
23ipRegex({exact: true}).test('unicorn 192.168.0.1');
24//=> false
25
26ipRegex.v6({exact: true}).test('1:2:3:4:5:6:7:8');
27//=> true
28
29'unicorn 192.168.0.1 cake 1:2:3:4:5:6:7:8 rainbow'.match(ipRegex());
30//=> ['192.168.0.1', '1:2:3:4:5:6:7:8']
31```
32
33
34## API
35
36### ipRegex([options])
37
38Returns a regex for matching both IPv4 and IPv6.
39
40### ipRegex.v4([options])
41
42Returns a regex for matching IPv4.
43
44### ipRegex.v6([options])
45
46Returns a regex for matching IPv6.
47
48#### options.exact
49
50Type: `boolean`<br>
51Default: `false` *(Matches any IP address in a string)*
52
53Only match an exact string. Useful with `RegExp#test()` to check if a string is an IP address.
54
55
56## Related
57
58- [is-ip](https://github.com/sindresorhus/is-ip) - Check if a string is an IP address
59
60
61## License
62
63MIT © [Sindre Sorhus](https://sindresorhus.com)
Note: See TracBrowser for help on using the repository browser.