DEV Community

James Perkins
James Perkins

Posted on

Regexits- Common regex at your fingertips

What is Regexits?

Regexits is a lightweight npm package that handles a collection of commonly used regex patterns.

Why would you need it?

I suppose the answer is, you hate googling regex when you need to verify a SSN, PhoneNumber, or even URLSlug.

How to use it

Well the good news is, that part is simple.

npm i regexits

Then in your code

const regexits= require('regexits')

regexits(string, pattern)

What options do you currently have?

  • Date With Slashes
  • Time in 24hr
  • ISO8601 Date and time
  • HTML tag
  • HEX Color
  • URLSlug
  • Src Img Tag
  • URL
  • Positive Int
  • Negative Int
  • Integer
  • Positive Num
  • Negitive Num
  • Number
  • Phone Number
  • New Line
  • CSS Comment
  • USA & Canada Zip
  • SSN

A Quick example

const regexits = require('regexits')

let isSSN = regexits('012-34-5678', 'SSN')

return isSSN;

#This Returns true

So overall its a pretty flexible tool that covers a collection of Regex that is commonly used over and over again. I will continuously updating the npm package along with my other open source tools.

Want a new pattern added just go ahead and add an issue via github and I will add it and republish the npm package.

Want to keep up to date with the npm package? check it out over at npm

Top comments (2)

damirtomic profile image

Here's a few more suggestions:

email, IPv4 (with and without subnet), IPv6 (with and without subnet + short and long way of writing IPv6), website

perkinsjr profile image
James Perkins


Good news!

The following were added late yesterday:

and URL(http, https, ftp file//) and Email were there but apparently I forgot to add them to the list