regex-collection
v1.0.1
Published
Useful regex patterns and functions to test them.
Downloads
93
Maintainers
Readme
Useful regex patterns and functions to test them.
Currently using 268
tests for 9
functions to ensure accurate results!
:white_check_mark: Supported patterns for:
- CSS comments
- Email addresses
- Full numbers / Integer
- Full numbers / Integer (Negative)
- Full numbers / Integer (Positive)
- Hex color codes
- IP addresses
- Telephone numbers
Documentation :clipboard:
:package: Install
npm i regex-collection
:clipboard: Usage
Importing
JavaScript
const search = require('regex-collection')
TypeScript
import * as search from 'regex-collection'
Syntax
The syntax is the same for JavaScript and TypeScript
get
Get all occurrences of regex
const text = "Hello World [email protected] Bye World [email protected]"
let result = search.getEmailAddress(text)
// => ["[email protected]", "[email protected]"]
is
Check if a string matches to a regex
const text = "Hello World [email protected] Bye World [email protected]"
let result = search.isEmailAddress(text)
// => false
const text = "[email protected]"
let result = search.isEmailAddress(text)
// => true