Shared regular expression definitions for NodeDK applications.
No dependencies. Patterns are exported directly as RegExp objects.
npm i @nodedk/regexp
var regexp = require('@nodedk/regexp')
regexp.email.test('hello@example.com') // true
regexp.slug.test('hello-world') // true
These patterns preserve the definitions from @nodedk/tools.
| Pattern | Matches |
|---|---|
email |
Non-whitespace name@domain.suffix format |
id |
At least 24 lowercase letters or digits |
reg |
Encoded %r/pattern/flags prefix, with i and g flags |
date |
Timestamp string format, not calendar validity |
url |
HTTP(S) or www. address within a string |
slug |
One or more lowercase letters, digits, hyphens, or underscores |
ip |
IPv4 address |
image |
GIF, JPEG, TIFF, PNG, BMP, or SVG filename extension |
domain |
Domain format with an optional subdomain |
subdomain |
2–63 lowercase letters, digits, hyphens, or underscores, with alphanumeric ends |
npm test
Created by Vidar Eldøy