I have a string(numbers only) and I want to replace a specific number with string.Empty. I am using string.Replace but the issue is it replaces the given number from all numbers. I've also tried Regex.Replace but getting same result.
For example,
Code:
string original = "301, 3301, 2301, 5301, 8301";
string modified = original.Replace("301", string.Empty);
string usingRegex = Regex.Replace(original, "301", string.Empty);
Actual Result:
", 3, 2, 5, 8"
Expected Result:
"3301, 2301, 5301, 8301"
,, remove the ones you don't want (easy with LINQ), thenstring.Jointhe rest back together.