C# string operation -
this question has answer here:
- get substring - before char 5 answers
i have string:
string str = "abc = def; \r\n header \r\n { \r\n def"
in string want string before character {
i.e, "header".
i can index of {
str.indexof('{')
but how can string before '{' ?
edited after codecaster comment
string str = "abc = def; \r\n header \r\n { \r\n def" int length = str.indexof('{'); // if there no match - resulted value -1 string result = (length < 0) ? string.empty : str.substring(0, length);
Comments
Post a Comment