Created
November 19, 2014 12:07
-
-
Save mattcanty/e4c193be089c1b018e86 to your computer and use it in GitHub Desktop.
Turn "SomethingLikeThis" into "Something Like This"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Text.RegularExpressions; | |
namespace Spin.TradingServices.Common.Library.Extensions | |
{ | |
public static class StringExtensions | |
{ | |
private const string CamelToSpacedRegexString = | |
@"(?<=[A-Z])(?=[A-Z][a-z])|(?<=[^A-Z])(?=[A-Z])|(?<=[A-Za-z])(?=[^A-Za-z])"; | |
private static readonly Regex CamelToSpacedRegex = new Regex(CamelToSpacedRegexString, | |
RegexOptions.IgnorePatternWhitespace); | |
public static string FromCamelToSpaced(this string camelString) | |
{ | |
return CamelToSpacedRegex.Replace(camelString, " "); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment