Hi,

I want to do the following:

"Pete jan jan john jan mark" --> "Pete B jan john jan mark"

So I would like to wite a RegEx that would replace the first occurence of
the matched string (in this case replacing "jan" by "B")
.replace replaces all occurences, but maybe a smart regex would solve that,
or let them find all occurences and use MatchEvaluator to only replace the
first and copy all the others back?
Any good Ideas?


Best Regards,

Jeroen Vandezande.

Re: System.Text.RegularExpressions by BertC

BertC
Tue May 10 11:16:03 CDT 2005

Jeroen,

The Replace method on the Regex object has an overloaded method that
allows you to specify how many times you want to perform the
replacement. That should allow you to limit the replacement to only
the first occurence.


Re: System.Text.RegularExpressions by Jeroen

Jeroen
Tue May 10 16:11:12 CDT 2005

great ! that is the solution.
Thank you

Jeroen

"BertC" <bert.cushman@formationsystems.com> wrote in message
news:1115741763.118698.27920@f14g2000cwb.googlegroups.com...
> Jeroen,
>
> The Replace method on the Regex object has an overloaded method that
> allows you to specify how many times you want to perform the
> replacement. That should allow you to limit the replacement to only
> the first occurence.
>