import { type ArrayOrValue } from '../array/array'; import { type DecisionFunction } from '../value/decision'; /** * Result describing the first and last index positions of a character within a string. */ export interface FirstAndLastCharacterOccurrence { /** * Index of the first occurrence, or -1 if the character was not found. */ readonly first: number | -1; /** * Index of the last occurrence, or -1 if the character was not found. */ readonly last: number | -1; /** * Total number of occurrences. */ readonly occurences: number; } /** * Finds the first and last occurrence of a single character within the input string. * * @param input - String to search through. * @param find - Single character to find. * @returns An object containing the first index, last index, and total occurrence count. * @throws {Error} If find is not exactly one character long. */ export declare function firstAndLastCharacterOccurrence(input: string, find: string): FirstAndLastCharacterOccurrence; /** * Checks whether the input string contains the given substring. * * @param input - String to search within. * @param find - Substring to search for. * @returns True if the substring is found within the input. */ export declare function stringContains(input: string, find: string): boolean; /** * Function that replaces the last character with the configured replacement string if it is any of the configured values. */ export type ReplaceLastCharacterIfIsFunction = (input: string) => string; /** * Creates a function that replaces the last character of a string with the replacement string * if that character matches any of the specified values. * * @param replacement - String to substitute for the last character. * @param is - Character(s) that trigger the replacement. * @returns Conditionally replaces the last character. * * @dbxUtil * @dbxUtilCategory string * @dbxUtilKind factory * @dbxUtilTags string, replace, last, character, conditional, factory * @dbxUtilRelated replace-last-character-if, replace-character-at-index-if * * @__NO_SIDE_EFFECTS__ */ export declare function replaceLastCharacterIfIsFunction(replacement: string, is: ArrayOrValue): ReplaceLastCharacterIfIsFunction; /** * Replaces the last character of a string with the replacement if the decision function returns true for that character. * * @param input - String to potentially modify. * @param replacement - String to substitute for the last character. * @param decision - Function that determines whether the last character should be replaced. * @returns The modified string, or the original if the decision is false or the string is empty. */ export declare function replaceLastCharacterIf(input: string, replacement: string, decision: DecisionFunction): string; /** * Replaces the character at the given index with the replacement string if the decision function returns true for that character. * * @param input - String to potentially modify. * @param index - Character index to evaluate. * @param replacement - String to substitute at the index. * @param decision - Function that determines whether the character should be replaced. * @returns The modified string, or the original if the decision is false. */ export declare function replaceCharacterAtIndexIf(input: string, index: number, replacement: string, decision: DecisionFunction): string; /** * Replaces the character at the given index with the replacement string. * * @param input - String to modify. * @param index - Character index to replace. * @param replacement - String to substitute at the index. * @returns The string with the character at the index replaced. */ export declare function replaceCharacterAtIndexWith(input: string, index: number, replacement: string): string; /** * Splits the input string into two parts at the given character index. * * @param input - String to split. * @param index - Character index at which to split. * @param inclusive - If true, the character at the index is included in the tail; if false (default), it is excluded from both parts. * @returns A tuple of [head, tail] substrings. */ export declare function splitStringAtIndex(input: string, index: number, inclusive?: boolean): [string, string]; /** * Special UTF-8 character that is the starting character. * * Example usage is in Firebase string queries to restrict the string search to a specific string. */ export declare const UTF_8_START_CHARACTER = "\0"; /** * Special UTF-8 character that is very high. * * Example usage is in Firebase string queries as wildcards for searching: * * https://firebase.google.com/docs/database/rest/retrieve-data#range-queries */ export declare const UTF_PRIVATE_USAGE_AREA_START = "\uF8FF"; /** * Creates a lookup record mapping each character in the input string to its index position. * In case of duplicate characters, the last occurrence's index is used. * * @param chars - String whose characters become keys in the record. * @returns A record mapping each character to its index in the input string. */ export declare function stringCharactersToIndexRecord(chars: string): Record;