c# - String find and replace -
i have string like
string text="~aaa~bbb~ccc~bbbddd"; the input value : bbb
so in above string should remove value "~bbb"
the resulting string should be
text="~aaa~ccc~bbbddd";
i'm not sure wanna if i've got can :
private string replacefirstoccurrence(string source, string find, string replace) { int place = source.indexof(find); string result = source.remove(place, find.length).insert(place, replace); return result; } var result =replacefirstoccurrence(text,"~"+input,"");
Comments
Post a Comment