Including missing essential functions for Regex
npm install regex-extra
!Logo
Including missing essential functions for Regex. (ESM Only)
construct core class with regex, and all the following functions are bind to the instance.
``ts`
const RE = /\d+/
const reg = new RegexExtra(RE)
`ts`
interface FindAtResult {
value: string
end: number
}
function findAt(str: string, start?: number, end?: number): FindAtResult | null
Pass start and end index to find the string.
`ts`
function isMatch(str: string, start?: number, end?: number): boolean
Pass string to check if the regex is matched.
`ts``
function captures(str: string, start?: number, end?: number): string[] | null
Get all the captures.