question about string.replace

kpao

Active member
Joined
Apr 3, 2006
Messages
29
Programming Experience
Beginner
Is it possible to do the following:

String : "I am in office now"
Replacement : "I am in e1ffice ne2w"
 
Not with String.Replace method you can't, but you can search out string with multiple calls to String.IndexOf, some of the overloads of this method allows to start search from specified index so you can start from previous match. You can also use Regex.Replace with a MatchEvaluator delegate method where you customize the replacement for each match.
 
Back
Top