this question has answer here:
how convert "thisismyteststring" "this test string" using c#?
is there fast way it?
i've been thinking of pseudo code it's complicated , ugly:
string s = "thisismyteststring"; list<string> strlist = new list<string>(); for(int i=0; < str->length ; i++) { string tmp = ""; if (char.isupper(str[i])) { tmp += str[i]; i++; } while (char::islower(str[i])) { tmp += str[i]; i++; } strlist .add(tmp); } string tmp2 = ""; (uint i=0 ; i<strlist.count(); i++) { tmp2 += strlist[i] + " "; }
you can use regex outlined here:
regular expression, split string capital letter ignore tla
your regex: "((?<=[a-z])[a-z]|a-z)"
find , replace " $1"
string splitstring = replace("thisismyteststring", "((?<=[a-z])[a-z]|[a-z](?=[a-z]))", " $1")
here (?<=...)
"positive lookbehind, regex should precede match. in case lookbehind "characters 'a' through 'z'" (?=...)
similar construct lookahead, match has followed regex-described string. in case lookahead "characters 'a' through 'z'" in both cases final match contains 1 character "a" through "z" followed 'a'-'z' or 1 character 'a' through 'z' followed capital letter. replacing these matches puts space between capital , lowercase letters
Comments
Post a Comment