Install to your existing project using:
npm i @spongex/regexps
Include ECMAScript:
import { testHexColor } from '@spongex/regexps'
Include CommonJS:
const { testAlpha } = require('@spongex/regexps')
Replaces newlines (\r\n, \r, \n) with another string. Returns the modified string.
const resStr = replaceNewlines(oldStr, '<br/>')
Test if a valid hexadecimal color value. Allows for alpha channel. Returns true if valid, else false.
const res = testHexColor('#FF00FF')
Test if a valid RGB(a) or HSL(a) value. Returns true if valid, else false.
const res = testRGB('rgba(255, 255, 255, 0.5)')
Test for a valid pixel format (NNpx). Returns true if valid, else false.
const res = testPixel('12px')
Test if charecters are all alphabetic. Returns true if valid, else false.
const res = testAlpha('ABCD')
Test if charecters are all numeric. Returns true if valid, else false.
const res = testNumeric('1234')
Test if only alphabectic and numeric charecters. Returns true if valid, else false.
const res = testAlphaNumeric('ABC123')
Tests a string for valid hex values. Returns true if valid, else false.
const res = validHex('0f9dacdc')
- Added two new functions
replaceNewlines
andvalidHex
- Initial release