0.2.2 • Published 5 months ago
regex-extra v0.2.2
regex-extra
Including missing essential functions for Regex. (ESM Only)
Usage
construct core class with regex, and all the following functions are bind to the instance.
const RE = /\d+/
const reg = new RegexExtra(RE)
Functions
1. findAt
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.
2. isMatch
function isMatch(str: string, start?: number, end?: number): boolean
Pass string to check if the regex is matched.
3. captures
function captures(str: string, start?: number, end?: number): string[] | null
Get all the captures.