Tuesday, 15 September 2015

Need to get a string after a "word" in a string in c# -



Need to get a string after a "word" in a string in c# -

i'm having string in c# have find specific word "code" in string , have remaining string after word "code".

the string

"error description, code : -1"

so have find word code in above string , have error code. have seen regex understood. there simple way ?

string tobesearched = "code : " string code = mystring.substring(mystring.indexof(tobesearched) + tobesearched.length);

something this?

perhaps should handle case of missing code :...

string tobesearched = "code : " int ix = mystring.indexof(tobesearched); if (ix != -1) { string code = mystring.substring(ix + tobesearched.length); // here }

c# string substring

No comments:

Post a Comment