nelson.lang.makeUniqueStrings
Make strings unique by adding numeric suffixes.
📝Syntax
U = nelson.lang.makeUniqueStrings(S)
U = nelson.lang.makeUniqueStrings(S, excludedStrings)
U = nelson.lang.makeUniqueStrings(S, whichStringsIdx)
U = nelson.lang.makeUniqueStrings(S, excludedStrings, maxStringLength)
U = nelson.lang.makeUniqueStrings(S, whichStringsIdx, maxStringLength)
[U, modified] = nelson.lang.makeUniqueStrings(...)
📥Input Arguments
Parameter Description
S string array, character vector, or cell array of character vectors.
excludedStrings strings that generated values must not duplicate.
whichStringsIdx numeric indices or logical mask selecting which elements to make unique. This argument is used instead of excludedStrings.
maxStringLength positive integer scalar maximum output length.
📤Output Arguments
Parameter Description
U unique strings, returned with the same text container type as S.
modified logical array indicating which input elements were changed.
📄Description

nelson.lang.makeUniqueStrings appends suffixes such as _1 and _2 to selected elements until they are unique.

💡Examples
nelson.lang.makeUniqueStrings({'a', 'a', 'b', 'a'})
nelson.lang.makeUniqueStrings({'a', 'b'}, {'a', 'b'})
🔗See Also
nelson.lang.makeValidNamenamelengthmax
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub