Regex.Replace: replace only first one found [duplicate]
Possible Duplicate:
How to Regex search/replace only first occurrence in a string in .NET?
How do I make Regex.Replace replace only 开发者_如何学JAVAthe first found pattern?
What about Regex.Replace ( String, String, Int32 )
(MSDN) ?
An example:
Regex rgx = new Regex(pattern);
string result = rgx.Replace(str, replacement, 1); // The 1 makes the difference
http://msdn.microsoft.com/en-us/library/haekbhys.aspx
you can use Regex.Replace(input, replacement, count);
精彩评论