Function isRepeating

  • Namespace

    StringUtils

    Checks if the given string contains repeated characters consecutively based on the specified limit.

    Parameters

    • input: string

      The string to check for repeated characters.

    • limit: number

      The maximum number of consecutive repeated characters allowed.

    Returns boolean

    True if the string contains repeated characters within the specified limit, false otherwise.

    Example

    const stringWithRepeated = "P@sswwoorrd";
    const hasRepeated = StringUtils.repeating(stringWithRepeated, 2);
    console.log(hasRepeated); // Output: true (The string contains 'ss', 'oo', 'rr' which are repeated characters within the limit)

    Example

    const stringWithoutRepeated = "SecurePass123!";
    const hasRepeated = StringUtils.repeating(stringWithoutRepeated, 2);
    console.log(hasRepeated); // Output: false (The string does not contain repeated characters within the limit)

Generated using TypeDoc