npm.io
1.0.1 • Published 6 years ago

regex-collection

Licence
MIT
Version
1.0.1
Deps
0
Size
27 kB
Vulns
0
Weekly
0
Stars
2

REGEX-COLLECTION

NPM CodeFactor Grade Travis (.org) GitHub package.json version npm npm bundle size

Useful regex patterns and functions to test them.

Currently using 268 tests for 9 functions to ensure accurate results!

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


Install

npm i regex-collection

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 contact@example.com Bye World hello@world.com"

let result = search.getEmailAddress(text)
// => ["contact@example.com", "hello@world.com"]
is Check if a string matches to a regex
const text = "Hello World contact@example.com Bye World hello@world.com"

let result = search.isEmailAddress(text)
// => false
const text = "contact@example.com"

let result = search.isEmailAddress(text)
// => true