Skip to content

Convert text to title case

Converts a source string to title case via TitleCase.ToTitleCase / String.ToTitleCase, preserving all original delimiter characters and applying acronym/minor-word/suffix overrides.

Field Value
Operation ID op-01-convert-to-title-case
Trigger A caller formats a stored text value for display (e.g. clsPolicyAssociation.PolicyName)
Inputs inString As String
Outputs Title-cased string preserving all original delimiter characters
Primary components TitleCase.ToTitleCase, String.ToTitleCase, ReassembleString, ApplyExactSuffixList
Entry point SAIF.Business.Utilities/TitleCase.vb

Steps

  1. Guard: if inString is Nothing or trims to zero length, return the input unchanged (BR-001). No exception is raised.
  2. Split inString.Trim on Regex.Split(..., "[^\d\w]") — every non-letter/non-digit character becomes a split point, producing word tokens and empty strings where consecutive delimiters occurred.
  3. If no token is non-blank, keep the original string (BR-002) and skip steps 4–5.
  4. Otherwise map each token through Case a single word, then call ReassembleString to rebuild the string, re-inserting the delimiter characters from the source at their original positions (BR-003). Leading delimiters are clipped off first, emitted verbatim, and the remainder is reassembled recursively.
  5. Split the reassembled result on spaces and apply ApplyExactSuffixList to each word — normalizes an 's-style suffix to the canonical casing in MixedCaseSuffixList (BR-010).
  6. Force the first character to upper case and return (BR-011).

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start([Caller invokes ToTitleCase]) --> Guard{Null/blank?}
    Guard -->|Yes| ReturnUnchanged([Return input unchanged])
    Guard -->|No| Split["Split into tokens on<br>non-alnum delimiters"]
    Split --> AnyToken{Any non-blank token?}
    AnyToken -->|No| KeepOriginal([Keep original string])
    AnyToken -->|Yes| MapTokens["Map each token via<br>TitleCaseSingleWord"]
    MapTokens --> Reassemble["Reassemble with original<br>delimiters"]
    Reassemble --> Suffix["Apply ApplyExactSuffixList<br>to each word"]
    Suffix --> ForceFirst["Force first character upper<br>case"]
    ForceFirst --> Done([Return title-cased string])

Failure and edge-case behavior

  • No Try/Catch. A source string whose delimiter positions do not align with the reassembly index can surface an index-out-of-range from inSourceString.ElementAt(...).**

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • SAIF.Business.Utilities/TitleCase.vb