Użyj tej s regex (zapomniałem, z którego stackoverflow Odpowiedź pozyskiwaniem go, będzie go szukać teraz):
public static string ToLowercaseNamingConvention(this string s, bool toLowercase)
{
if (toLowercase)
{
var r = new Regex(@"
(?<=[A-Z])(?=[A-Z][a-z]) |
(?<=[^A-Z])(?=[A-Z]) |
(?<=[A-Za-z])(?=[^A-Za-z])", RegexOptions.IgnorePatternWhitespace);
return r.Replace(s, "_").ToLower();
}
else
return s;
}
Używam go w tym projekcie: http://www.ienablemuch.com/2010/12/intelligent-brownfield-mapping-system.html
[EDIT]
znalazłem go teraz: How do I convert CamelCase into human-readable names in Java?
Ładnie split "TodayILiveInTheUSAWithSimon", nie ma miejsca na froncie "Today":
using System;
using System.Text.RegularExpressions;
namespace TestSplit
{
class MainClass
{
public static void Main (string[] args)
{
Console.WriteLine ("Hello World!");
var r = new Regex(@"
(?<=[A-Z])(?=[A-Z][a-z]) |
(?<=[^A-Z])(?=[A-Z]) |
(?<=[A-Za-z])(?=[^A-Za-z])", RegexOptions.IgnorePatternWhitespace);
string s = "TodayILiveInTheUSAWithSimon";
Console.WriteLine("YYY{0}ZZZ", r.Replace(s, " "));
}
}
}
wyjściowa:
YYYToday I Live In The USA With SimonZZZ
Dzielenie sugeruje, że chcesz mieć tablicę ciągów, ale wygląda na to, że chcesz wstawić spacje w łańcuchu znaków? – Guffa