Skip to content

1337z/regex-collection

Repository files navigation

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

📦 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 [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