I’m trying to write a regex that will take a string of the form:
<123>, ;<123>:::,<123>
where 123 is some number and in between the numbers is some punctuation.
I need a regex that will replace all the punctuation between the number fields with “”.
I tried this:
Regex.Replace(s, ">.*<", "");
But had no luck. What regex would accomplish this?
Edit: My original regex was a bit misleading, sorry! As the commenters said, I’m looking for <123><123><123>
Not sure about the exact C# syntax either, but if your string is guaranteed not to have numbers outside those angle brackets, then you should be able to get away with this:
So remove anything that isn’t a number or “<” or “>”. If you also want to remove the angle brackets it’s even simpler: