Skip to content

Instantly share code, notes, and snippets.

View web-crab's full-sized avatar

Andrey Klimash web-crab

View GitHub Profile
@web-crab
web-crab / patterns.js
Last active March 23, 2019 20:02 — forked from KhalilZaidoun/patterns.js
Useful Regex Patterns (Forked from Regex Hub)
export const patterns = [{
name:"Date in format dd/mm/yyyy",
regex:/^(0?[1-9]|[12][0-9]|3[01])([ /\-])(0?[1-9]|1[012])\2([0-9][0-9][0-9][0-9])(([ -])([0-1]?[0-9]|2[0-3]):[0-5]?[0-9]:[0-5]?[0-9])?$/,
description:"Will match dates with dashes, slashes or with spaces (e.g. dd-mm-yyyy dd/mm/yyyy dd mm yyyy), and optional time separated by a space or a dash (e.g. dd-mm-yyyy-hh:mm:ss or dd/mm/yyyy hh:mm:ss).",
tags:"date,time"
},
{
name:"Time in 24-hour format",
regex:/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/,
description: "Match times in 24 hour format",