regex-friendly
Version:
Readable regex transformations, validations, and utilities with both static and chainable API.
38 lines (37 loc) • 1.52 kB
TypeScript
/** Advanced pattern helpers and small builders. */
export declare const advanced: {
/** Positive lookahead fragment */
lookahead: (pattern: string) => string;
/** Negative lookahead fragment */
negativeLookahead: (pattern: string) => string;
/** Positive lookbehind fragment */
lookbehind: (pattern: string) => string;
/** Negative lookbehind fragment */
negativeLookbehind: (pattern: string) => string;
/** Wrap as a non-capturing group */
nonCapturing: (pattern: string) => string;
/** Named capturing group */
namedGroup: (name: string, pattern: string) => string;
/** Either/or */
or: (...patterns: string[]) => string;
/** Character class any-of */
anyOf: (chars: string) => string;
/** Character class none-of */
noneOf: (chars: string) => string;
/** Repeat {n} or {min,max} */
repeat: (pattern: string, min: number, max?: number, lazy?: boolean) => string;
/** Optional */
optional: (pattern: string, lazy?: boolean) => string;
/** One or more */
oneOrMore: (pattern: string, lazy?: boolean) => string;
/** Zero or more */
zeroOrMore: (pattern: string, lazy?: boolean) => string;
/** Anchors */
startsWith: (pattern: string) => RegExp;
endsWith: (pattern: string) => RegExp;
/** Word boundary wrappers */
word: (pattern: string) => RegExp;
notWordBoundary: () => RegExp;
/** Build a RegExp with flags from a source string */
build: (source: string, flags?: string) => RegExp;
};