regexp-pattern-utils
v1.0.1
Published
```typescript import regexpUtils = require('regexp-utils'); const { "emailPattern", "urlPattern", "phonePattern", "datePattern", "ipPattern", "hexColorPattern", "passwordPattern", "zipCodePattern", "lettersPattern", "number
Downloads
16
Maintainers
Keywords
Readme
import regexpUtils = require('regexp-utils');
const {
"emailPattern",
"urlPattern",
"phonePattern",
"datePattern",
"ipPattern",
"hexColorPattern",
"passwordPattern",
"zipCodePattern",
"lettersPattern",
"numbersPattern",
"ssnPattern",
"timePattern",
"positiveIntegerPattern",
"negativeIntegerPattern",
"integerPattern",
"decimalPattern",
"alphanumericPattern",
"whitespacePattern",
"noWhitespacePattern",
"htmlTagPattern",
"creditCardPattern",
"macAddressPattern",
"stateAbbreviationPattern",
"hexColorWithAlphaPattern",
"htmlOpeningTagPattern",
"htmlClosingTagPattern",
"htmlSelfClosingTagPattern",
"currencyPattern",
"markdownLinkPattern",
"base64Pattern",
"youtubeUrlPattern",
"uuidPattern",
"jsonStringPattern",
"domainNamePattern",
"htmlCommentPattern",
"unixFilePathPattern",
"windowsFilePathPattern",
"rgbColorPattern",
"rgbaColorPattern",
"cssVariablePattern",
"slugPattern",
"htmlEntityPattern",
"usernamePattern",
"creditCardCVVPattern",
"mimeTypePattern",
"latitudePattern",
"longitudePattern",
"isbn10Pattern",
"isbn13Pattern",
"time24HourPattern",
"time12HourPattern",
"xmlTagPattern",
"twitterHandlePattern",
"hexadecimalPattern",
"fileExtensionPattern",
"htmlAttributePattern",
"ssnWithDashesPattern",
"jsonDatePattern",
"creditCardNumberPattern",
"strongPasswordPattern",
"macAddressWithColonsPattern",
} = regexpUtils;
// Example usage
const email = '[email protected]';
if (emailPattern.test(email)) {
console.log('Valid email address');
} else {
console.log('Invalid email address');
}
const url = 'https://www.example.com';
if (urlPattern.test(url)) {
console.log('Valid URL');
} else {
console.log('Invalid URL');
}
const phoneNumber = '123-456-7890';
if (phonePattern.test(phoneNumber)) {
console.log('Valid phone number');
} else {
console.log('Invalid phone number');
}
const dateString = '2024-06-15';
if (datePattern.test(dateString)) {
console.log('Valid date');
} else {
console.log('Invalid date');
}
const ipAddress = '192.168.1.1';
if (ipPattern.test(ipAddress)) {
console.log('Valid IP address');
} else {
console.log('Invalid IP address');
}
const hexColor = '#FFA500';
if (hexColorPattern.test(hexColor)) {
console.log('Valid hex color');
} else {
console.log('Invalid hex color');
}
const password = 'Password@123';
if (passwordPattern.test(password)) {
console.log('Valid password');
} else {
console.log('Invalid password');
}
const zipCode = '12345';
if (zipCodePattern.test(zipCode)) {
console.log('Valid ZIP code');
} else {
console.log('Invalid ZIP code');
}
const letters = 'abcdEFG';
if (lettersPattern.test(letters)) {
console.log('Contains only letters');
} else {
console.log('Contains non-letter characters');
}
const numbers = '12345';
if (numbersPattern.test(numbers)) {
console.log('Contains only numbers');
} else {
console.log('Contains non-numeric characters');
}
export {};