i have a following type of string format —
Proposal is given to {Jwala Vora#3/13} for {Amazon Vally#2/11} {1#3/75} by {MdOffice employee#1/1}
the string contains pair of { } with different positions and may be n number of times.
now i want to replace that pair with other strings which i will compute depending on the string between { } pair.
how to do this ?
You could try regular expressions. Specifically,
Regex.Replacevariants usingMatchEvaluatorshould do the trick. See http://msdn.microsoft.com/en-US/library/cft8645c(v=vs.80).aspx for more information.Something along these lines:
This program will output
Proposal is given to xyz for xyz xyz by xyz.You’ll need to provide your app-specific logic in the
ReplaceMatchEvaluatormethod to processvalue0,value1andvalue2as appropriate. The classReplacercan contain additional members that can be used to implement the replacement logic inReplaceMatchEvaluator. Strings are processed by callingReplaceon an instance of theReplacerclass.