UNPKG

ts-regex-builder

Version:

Maintainable regular expressions for TypeScript and JavaScript.

27 lines (26 loc) 951 B
import type { EncodedRegex, RegexSequence } from '../types'; export type CaptureOptions = { /** * Name to be given to the capturing group. */ name?: string; }; export interface Reference extends EncodedRegex { name: string; } /** * Creates a capturing group which allows the matched pattern to be available: * - in the match results (`String.match`, `String.matchAll`, or `RegExp.exec`) * - in the regex itself, through {@link ref} */ export declare function capture(sequence: RegexSequence, options?: CaptureOptions): EncodedRegex; /** * Creates a reference, also known as backreference, which allows matching * again the exact text that a capturing group previously matched. * * In order to form a valid regex, the reference must use the same name as * a capturing group earlier in the expression. * * @param name - Name of the capturing group to reference. */ export declare function ref(name: string): Reference;