function regulalrizeString(displayName) {
    // THis function removes all spaces and non-alphanumeric characters from a string
    // and replaces the internal spaces with hyphens. It also converts all characters to lower case.
    // This produces a string is stylistically appropriate for IDs and class names and other uses
    // and removes characters that might be problematic like spaces, periods, etc.
    // This function returns a new string and does not modify the input string.
    //
    // The following code does this
    //    1. Trim leading and trailing white space (in case this wasn't already done)
    //    2. Substitute an underscore for any sequence of white space characters
    //       (leading and trailing white space was already eliminated with the trim function)
    //    3. Remove any non-alphanumeric characters (underscore is considered alphanumeric)
    //    4. Replace underscores with hyphens, for stylistic reasons: we use hyphens as separators
    //       in our ID and class names.
    //       (Why weren't the hyphens used instead of underscores in step 2? Because in step 3 the
    //        JavaScript regular expression matches alphanumeric characters; it considers underscore
    //        to be alphanumeric but it doesn't consider the hyphen to be alphanumeric.)

    return displayName
        .trim()                // Trim leading and trailing white space
        .replace(/\s+/g, "-")  // Substitute an hyphen for any sequence of white space characters
        .replace(/[^-A-Za-z0-9_]/g, '')    // Remove any non-alphanumeric characters (hyphens and underscores are also retained)
        .toLowerCase();        // Make ID all lower case
}

function convertDisplayNameToID({prefix = "",displayName}) {
    if (prefix !== "") {
        prefix = prefix + "-";
    }
    return prefix + regulalrizeString(displayName);
}

export {regulalrizeString, convertDisplayNameToID};