OpenSheetMusicDisplay
    Preparing search index...

    Class StringUtil

    Index
    • Checks whether the string contains the given word or phrase as a separate word, not as part of a longer word: it has to be at the start of the string or after a space, and at the end or before a space or period. E.g. with ignoreCase, "Menuetto D.C. al Fine" contains "d.c. al fine", and "To Coda." contains "coda", but "Codas" doesn't. To check whether the whole string is the word or phrase, use StringIsWord().

      Parameters

      • str: string

        the string to search

      • wordRegExString: string

        the word or phrase to find, given as a regular expression string (input for new RegExp()), so characters like "." need to be escaped

      • ignoreCase: boolean = false

        whether to match case-insensitively

      Returns boolean

      true if str contains the word or phrase as a separate word

    • Checks whether the entire string is the given word or phrase, i.e. doesn't just contain it within a longer text. Trailing spaces and periods are allowed, e.g. "D.C. al Fine." still matches "d.c. al fine".

      Parameters

      • str: string

        the string to check. Should already be trimmed (no leading/trailing whitespace).

      • wordRegExString: string

        the word or phrase to check for, given as a regular expression string (input for new RegExp())

      • ignoreCase: boolean = false

        whether to match case-insensitively

      Returns boolean

      true if str is (only) the given word or phrase