C# string operation -


this question has answer here:

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

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -