1.1.1 ā€¢ Published 3 years ago

theregex v1.1.1

Weekly downloads
5
License
MIT
Repository
github
Last release
3 years ago

Readme

Another JS/TS regexes with more feature!

Usage

import regex from 'theregex'

const oldSchool = /abc/
const withFlags = /def/gm
const myTheRegex = regex`\x42{5}`

const myCaseInsensitiveRegex = regex('i')`
	^
		${oldSchool}    # seamlessly interpolate other regexes
		${myTheRegex}   # also works if the other regex is fancy
    ${withFlags}    # flags ignored when interpolated

    \w\d\b\0\\      # look Mom, no double escaping!

    ...

		\r\n\t\x20      # use "\x20" to match a literal space
	$
`

console.log(myCaseInsensitiveRegex)
// /^abc\x42{5}def\w\d\b\0\\...\r\n\t\x20$/i

const myRegexWithOptions = regex({
	unicode: true,
	global: true,
})`
	^
		šŸ’©+    # with unicode enabled, this matches by codepoint
	$
`

console.log(myRegexWithOptions)
// /^šŸ’©+$/gu