Regexer
A simple and convenient library of functions that leverage regular expressions while hiding its complexity of implementation
Table of Contents
-
.isCreditCard()
.isDayOfMonth()
.isDayOfWeekString()
.isDecimal()
.isEmail()
.isHexValue()
.isHTMLTag()
.isInteger()
.isIPAddressV4()
.isLetter()
.isLowerCase()
.isMonthOfYear()
.isMonthOfYearString()
.isNegativeInteger()
.isNegativeNumber()
.isNumber()
.isPassword()
.isPositiveInteger()
.isPositiveNumber()
.isSSN()
.isStandardZipCode()
.isUpperCase()
.isUrl()
.isUsername()
.isUSPhoneNumber()
.isUSState()
.isVowel()
.isYear()
Why Regexer?
Regular expressions are awesome and absolutely super useful when it comes to looking for pattern matches in a string, but clearly it is not the easiest topic to get your head around. Don't believe me, just take a look!
Regexer just attempts to make the process of using some of the most popular regular expressions easier for you. You no longer need to look all over the place for finding a regular expression for matching an email or a phone number, or a hex value or even a day of the week. Just install regexer and use the built in common functions to verify candidate values.
Still confused...? Let's look at an example
Installation
Before we get going, make sure you have Node.js installed on your system, so we can use the NPM (Node Package Manager) to install regexer on your project.
$ npm install --save nsp-regexer
Usage
// ES5const regexer = ; console // trueconsole // false
// ES6+; console // falseconsole // true
API
.isCreditCard(creditCardNumber[number|string])
Returns true
if creditCardNumber is a valid credit card number, otherwise returns false
; // true // true // false
.isDayOfMonth(day[number|string])
Returns true
if day is a day of the month (1-31), otherwise returns false
; // true // true // false
.isDayOfWeekString(day[number|string])
Returns true
if day is name of a week day, otherwise returns false
; // true // true // true // true // false
.isDecimal(number[number|string])
Returns true
if number is a decimal number, otherwise returns false
; // true // true // false
.isEmail(email[string])
Returns true
if email is a valid email address, otherwise returns false
; // true // false
.isHexValue(hexValue[string])
Returns true
if hexValue is a valid hex value, otherwise returns false
; // true // true // true // false
.isHTMLTag(htmlTag[string])
Returns true
if htmlTag is an HTML tag, otherwise returns false
; // true // true // true // false
.isInteger(integer[number|string])
Returns true
if integer is an integer, otherwise returns false
; // true // true // false
.isIPAddressV4(ipAddress[string])
Returns true
if ipAddress a valid IP address, otherwise returns false
; // true // true // false
.isLetter(char[string])
Returns true
if char an alphabetic letter, otherwise returns false
; // true // true // false
.isLowerCase(str[string])
Returns true
if str contains all lower case letters, otherwise returns false
; // true // true // false
.isMonthOfYear(number[number|string])
Returns true
if number is a month of year (1-12), otherwise returns false
; // true // true // false
.isMonthOfYearString(month[string])
Returns true
if month is a name of a month of year, otherwise returns false
; // true // true // false
.isNegativeInteger(integer[number|string])
Returns true
if integer is a negative integer, otherwise returns false
; // true // true // false
.isNegativeNumber(number[number|string])
Returns true
if number is a negative number, otherwise returns false
; // true // true // true // false
.isNumber(number[number|string])
Returns true
if number is a number, otherwise returns false
; // true // true // true // false
.isPassword(password[string])
Returns true
if password meets simple ruleset of a password (contains letters, numbers, hyphens, and underscores; length is between 6 to 18 characters), otherwise returns false
; // true // true // false
.isPositiveInteger(integer[number|string])
Returns true
if integer is a positive integer, otherwise returns false
; // true // false
.isPositiveNumber(number[number|string])
Returns true
if number is a positive number, otherwise returns false
; // true // true // true // false
.isSSN(number[string])
Returns true
if number is a valid social security number, otherwise returns false
; // true // true // true // false
.isStandardZipCode(zipCode[string])
Returns true
if zipCode is a valid zip code, otherwise returns false
; // true // true // false
.isUpperCase(str[string])
Returns true
if str contains all upper case letters, otherwise returns false
; // true // true // false
.isUrl(url[string])
Returns true if url a valid URL address, otherwise returns false
; // true // true // false
.isUsername(username[string])
Returns true
if username meets the basic requirement of an username (contains letters, numbers, hyphens, and underscores; length is between 3 to 16 characters), otherwise returns false
; // true // true // false
.isUSPhoneNumber(phoneNumber[string])
Returns true
if phoneNumber a valid US phone number, otherwise returns false
; // true // true // false
.isUSState(state[string])
Returns true
if state a name of one of US state, otherwise returns false
; // true // true // false
.isVowel(char[string])
Returns true
if char a vowel letter, otherwise returns false
; // true // true // false
.isYear(number[number|string])
Returns true
if number a year, otherwise returns false
; // true // true // false
Obviously, more to come soon...!
Credits
Source code makes use of several open source packages, a few keys ones include...
- Babel - To transpile ES6+ syntax to ES5, to run source code in Node and browser
- Webpack - For module bundling and generating distributing assets
- ESLint - To lint source code for better readability, syntax consistency and proper formatting
- CircleCI - Continuous integration middleware to verify incremental builds are always passing
Support
You May Also Like...
- focus - A simple, elegant task manager application to help students and computer savvy workers get their work done efficiently and on time
- lists - Quickly draught down your todos, groceries, chores or any other lists of items quickly #powerOfLists