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