/** * Python re module for TypeScript * * Provides regular expression matching operations matching Python's re module, * including match, search, findall, sub, and split functions. * * @see {@link https://docs.python.org/3/library/re.html | Python re documentation} * @module */ /** Ignore case */ declare const IGNORECASE = 2; declare const I = 2; /** Multi-line mode */ declare const MULTILINE = 8; declare const M = 8; /** Dot matches all (including newline) */ declare const DOTALL = 16; declare const S = 16; /** Unicode matching (always on in JS) */ declare const UNICODE = 32; declare const U = 32; /** ASCII-only matching */ declare const ASCII = 256; declare const A = 256; declare class Match { private _match; private _string; private _pattern; private _pos; private _endpos; constructor(match: RegExpExecArray, string: string, pattern: Pattern, pos?: number, endpos?: number); /** Return the string matched by the RE */ group(groupNum?: number | string): string | undefined; /** Return a tuple containing all subgroups */ groups(defaultValue?: string): (string | undefined)[]; /** Return a dictionary of named groups */ groupDict(defaultValue?: string): Record; /** Return the start index of the match */ start(groupNum?: number): number; /** Return the end index of the match */ end(groupNum?: number): number; /** Return a tuple (start, end) */ span(groupNum?: number): [number, number]; /** Return start position of search */ get pos(): number; /** Return end position of search */ get endpos(): number; /** Return the last matched group index */ get lastIndex(): number | undefined; /** Return the name of the last matched group */ get lastGroup(): string | undefined; /** Return the pattern object */ get re(): Pattern; /** Return the input string */ get string(): string; /** Expand template with groups */ expand(template: string): string; /** Return iterator of all groups */ [Symbol.iterator](): Generator; toString(): string; } declare class Pattern { private _regex; private _pattern; private _flags; constructor(pattern: string, flags?: number); private _compileRegex; /** Search for pattern in string */ search(string: string, pos?: number, endpos?: number): Match | null; /** Match pattern at start of string */ match(string: string, pos?: number, endpos?: number): Match | null; /** Match pattern against entire string */ fullMatch(string: string, pos?: number, endpos?: number): Match | null; /** Split string by pattern */ split(string: string, maxsplit?: number): string[]; /** Find all matches */ findAll(string: string, pos?: number, endpos?: number): (string | string[])[]; /** Find all matches as iterator */ findIter(string: string, pos?: number, endpos?: number): Generator; /** Replace pattern in string */ sub(repl: string | ((match: Match) => string), string: string, count?: number): string; /** Replace pattern and return (newstring, count) */ subn(repl: string | ((match: Match) => string), string: string, count?: number): [string, number]; /** Return the pattern string */ get pattern(): string; /** Return the flags */ get flags(): number; /** Return number of groups */ get groups(): number; /** Return named groups mapping */ get groupIndex(): Record; toString(): string; } /** Compile a regular expression pattern */ declare function compile(pattern: string, flags?: number): Pattern; /** Search for pattern in string */ declare function search(pattern: string | Pattern, string: string, flags?: number): Match | null; /** Match pattern at start of string */ declare function match(pattern: string | Pattern, string: string, flags?: number): Match | null; /** Match pattern against entire string */ declare function fullMatch(pattern: string | Pattern, string: string, flags?: number): Match | null; /** Split string by pattern */ declare function split(pattern: string | Pattern, string: string, maxsplit?: number, flags?: number): string[]; /** Find all matches */ declare function findAll(pattern: string | Pattern, string: string, flags?: number): (string | string[])[]; /** Find all matches as iterator */ declare function findIter(pattern: string | Pattern, string: string, flags?: number): Generator; /** Replace pattern in string */ declare function sub(pattern: string | Pattern, repl: string | ((match: Match) => string), string: string, count?: number, flags?: number): string; /** Replace pattern and return (newstring, count) */ declare function subn(pattern: string | Pattern, repl: string | ((match: Match) => string), string: string, count?: number, flags?: number): [string, number]; /** Escape special characters in pattern */ declare function escape(pattern: string): string; /** Purge the regex cache (no-op in this implementation) */ declare function purge(): void; declare const reModule_A: typeof A; declare const reModule_ASCII: typeof ASCII; declare const reModule_DOTALL: typeof DOTALL; declare const reModule_I: typeof I; declare const reModule_IGNORECASE: typeof IGNORECASE; declare const reModule_M: typeof M; declare const reModule_MULTILINE: typeof MULTILINE; type reModule_Match = Match; declare const reModule_Match: typeof Match; type reModule_Pattern = Pattern; declare const reModule_Pattern: typeof Pattern; declare const reModule_S: typeof S; declare const reModule_U: typeof U; declare const reModule_UNICODE: typeof UNICODE; declare const reModule_compile: typeof compile; declare const reModule_escape: typeof escape; declare const reModule_findAll: typeof findAll; declare const reModule_findIter: typeof findIter; declare const reModule_fullMatch: typeof fullMatch; declare const reModule_match: typeof match; declare const reModule_purge: typeof purge; declare const reModule_search: typeof search; declare const reModule_split: typeof split; declare const reModule_sub: typeof sub; declare const reModule_subn: typeof subn; declare namespace reModule { export { reModule_A as A, reModule_ASCII as ASCII, reModule_DOTALL as DOTALL, reModule_I as I, reModule_IGNORECASE as IGNORECASE, reModule_M as M, reModule_MULTILINE as MULTILINE, reModule_Match as Match, reModule_Pattern as Pattern, reModule_S as S, reModule_U as U, reModule_UNICODE as UNICODE, reModule_compile as compile, reModule_escape as escape, reModule_findAll as findAll, reModule_findIter as findIter, reModule_fullMatch as fullMatch, reModule_match as match, reModule_purge as purge, reModule_search as search, reModule_split as split, reModule_sub as sub, reModule_subn as subn }; } export { A, DOTALL as D, I, M, Pattern as P, S, U, ASCII as a, IGNORECASE as b, MULTILINE as c, Match as d, UNICODE as e, compile as f, escape as g, findAll as h, findIter as i, fullMatch as j, split as k, sub as l, match as m, subn as n, purge as p, reModule as r, search as s };