/** * Transformation applied to the extracted usernames. * @typedef {'lowercase' | 'uppercase' | ((username: string) => string) | null} UsernameTransform */ export type UsernameTransform = 'lowercase' | 'uppercase' | ((username: string) => string) | null; export type UsernameRegexOptions = { /** * The allowed characters for the username part. */ validValues?: string; /** * The [min, max] length of the username part. */ length?: [number, number]; /** * A regex pattern defining the required characters at the start of the username. */ start?: string; /** * A regex pattern defining the required characters at the end of the username. */ end?: string; /** * An optional prefix like '@' or '#'. */ prefix?: string; /** * A literal domain string (e.g., '@matrix.org'). Will be escaped automatically. */ domain?: string; /** * A regex pattern for a domain (e.g., '@[a-z0-9.-]+\\.[a-z]{2,}'). */ domainPattern?: string; /** * Optional transformation applied to the extracted usernames. */ transform?: UsernameTransform; }; export type UsernameOptionsInput = UsernameRegexOptions | UsernameRegexOptions[]; /** * Builds the core part of a username regular expression based on character rules and length. * @param {UsernameRegexOptions} [options] The options for the core pattern. * @returns {string} The regex string for the core username part. */ export declare const usernameStringRegexBuilder: ({ validValues, length, }?: UsernameRegexOptions) => string; /** * Constructs a complete regular expression for matching a username. * @param {UsernameOptionsInput} [options] The options for constructing the regex. * @returns {RegExp} The constructed regular expression object. */ export declare function usernameRegex(options?: UsernameOptionsInput): RegExp; /** * Validates whether a string matches the specified username pattern. * @param {string} s The input string to validate. * @param {UsernameOptionsInput} [options] The regex construction options. * @param {RegExp} [regex] - The regex used to execute the function. * @returns {boolean} True if the string is a valid username, false otherwise. * @throws {TypeError} If the input is not a string. */ export declare function isValidUsername(s: string, options?: UsernameOptionsInput, regex?: RegExp): boolean; /** * Generates a global regular expression to find usernames within a text. * @param {UsernameOptionsInput} [options] The options for the regex. * @returns {RegExp} The global regular expression for finding usernames. */ export declare function findUsernameRegex(options?: UsernameOptionsInput): RegExp; /** * Extracts usernames from a text and applies optional transformations. * @param {string} text The text to search through. * @param {UsernameOptionsInput} [options] The options for extraction. * @param {RegExp} [regex] - The regex used to execute the function. * @returns {string[]} An array of extracted and transformed usernames. * @throws {TypeError} If the input text is not a string. */ export declare function extractUsernames(text: string, options?: UsernameOptionsInput, regex?: RegExp): string[]; //# sourceMappingURL=index.d.mts.map