fcsIT
asked on
C#.net subtract value from string using a regular expression
I'm using the regular expression shown below to find a given string in a text file. That parts works. The problem is that I need to subtract 7 from the number in that string in the file. My code below is currently just writing SE*[d-[7]]*0001~ to the text file instead of updating it. That makes sense since I put that in the replace portion of the command, but I don't know how to make this work otherwise. Any ideas?
Here is an example of the string I need to subtract 7 from:
SE*2078*0001~
I need it to say:
SE*2071*0001~
File.WriteAllText(
file,
Regex.Replace(File.ReadAllText(file), @"SE\*\d+\*0001~", "SE*[d-[7]]*0001~", RegexOptions.Multiline)
);
Here is an example of the string I need to subtract 7 from:
SE*2078*0001~
I need it to say:
SE*2071*0001~
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER