Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/Humanizer/StringHumanizeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,19 @@ public static partial class StringHumanizeExtensions
private static Regex FreestandingSpacingCharRegex() => FreestandingSpacingCharRegexField;
#endif

static string FromUnderscoreDashSeparatedWords(string input) =>
string.Join(" ", input.Split(['_', '-']));
static string FromUnderscoreDashSeparatedWords(string input)
{
#if NET7_0_OR_GREATER
return string.Create(input.Length, input, (span, state) =>
{
state.AsSpan().CopyTo(span);
span.Replace('_', ' ');
span.Replace('-', ' ');
});
#else
return input.Replace('_', ' ').Replace('-', ' ');
#endif
}

static string FromPascalCase(string input)
{
Expand Down Expand Up @@ -160,4 +171,4 @@ internal static unsafe string Concat(char left, CharSpan right) =>
internal static unsafe string Concat(CharSpan left, char right) =>
Concat(left, new CharSpan(&right, 1));
#endif
}
}
Loading