Skip to content

Keep a letter after a digit in the same word in Title, Pascal and Camel case [patch] - #107

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/78-letter-after-digit
Oct 6, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/78-letter-after-digit

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #78

What changed

This follows the maintainer's decision on the issue: a letter after a digit does not start a new word.

TextInfo.ToTitleCase capitalised any letter that came straight after a digit. As a result, "1st place" became "1St Place", and Title, Pascal and Camel case disagreed with Snake, Kebab and Macro case. ToTitleCase now runs a new LowercaseLettersAfterDigits step after title-casing, which lowers each letter that directly follows a digit. Everything else TextInfo does stays as it was, including its handling of apostrophes, punctuation and the dotted and dotless I.

Input Title Pascal Snake
1st place 1st Place 1stPlace 1st_place
abc123def Abc 123def Abc123def abc_123def
md5hash Md 5hash Md5hash md_5hash
3d model 3d Model 3dModel 3d_model

Tests

  • ALetterAfterADigitShouldNotStartANewWord covers the four inputs from the issue. For each one it checks that x.ToSnakeCase() equals x.ToPascalCase().ToSnakeCase(), and does the same through camelCase and Title case.
  • With the source change reverted, the new test fails on the Title-case assertion: it gets "1St Place" where it expects "1st Place".
  • The full suite passes on net10.0 (121 tests), and the library builds for every target framework with no warnings.

🤖 Generated with Claude Code

https://claude.ai/code/session_015ef5k7pqkftQmMd6x5w9xM


Generated by Claude Code

…el case [patch]

TextInfo.ToTitleCase capitalises a letter that follows a digit, so
"1st place" became "1St Place" and "abc123def" became "Abc123Def",
while snake_case, kebab-case and MACRO_CASE kept "1st" and "123def"
whole. ToPascalCase().ToSnakeCase() therefore disagreed with
ToSnakeCase().

ToTitleCase now lowers each letter that directly follows a digit after
title-casing, so every converter treats digit-to-letter as part of the
same word.

Fixes #78

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ef5k7pqkftQmMd6x5w9xM
@sonarqubecloud

sonarqubecloud Bot commented Oct 5, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A letter after a digit starts a new word in Title/Pascal/Camel but not in Snake/Kebab: "1st place" → "1St Place", "abc123def" → "abc_123def"

2 participants