Tweakr
    Preparing search index...

    Function getHonorificSuffix

    • Returns the honorific suffix from a string if present.

      This function checks the input string for any known honorific suffixes (e.g., "Jr.", "Sr.", "III") and returns the first match found. It trims the input string before checking and considers suffixes both with and without a leading space.

      Parameters

      • str: string

        The string to search for an honorific suffix.

      Returns null | string

      The matched honorific suffix, or null if none is found.

      1.2.0

      getHonorificSuffix("John Doe Jr."); // Returns "Jr."
      getHonorificSuffix("Jane Smith"); // Returns null