Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

RegEx.Replace - How to replace only the first 2 occurency of a string

0 views
Skip to first unread message

Harry Pfleger

unread,
Apr 15, 2003, 4:40:49 PM4/15/03
to
Is it possible to implement a RegEx solution, which changes only the first
two occurency of a certain string in another string.

eg.

string myString = "Blue Red Blue Red Blue";
string oldValue = "Blue";
string newValue = "Green";

... do the RegEx replacement ...

result should be: "Green Red Green Red Blue"


thankx Harry


Ryan Trudelle-Schwarz

unread,
Apr 15, 2003, 5:32:10 PM4/15/03
to
"Harry Pfleger" <ha...@ardimedia.com> wrote

Look at the overloads of the Replace method, many of them take a count
parameter for doing just that.


0 new messages