using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"((?:bs )?(?:en )?(?:np )?(?:is[o0]|DIN)\s+[-\d]+:)(.+:)?(\d{4}(?:\(\w\))?)";
string substitution = @"$1$3";
string input = @"ISO 11784:1996/Amd.2:2010(E)
ISO 11784:2010(E)
ISO 11784:2010
ISO 11784-2-3-4:1996/Amd.2:2010(E)
ISO 11784-2-8-7:2010(E)
ISO 11784-5-120-78949-56-789:2010
BS EN ISO 11784:1996/Amd.2:2010(E)
EN ISO 11784:2010(E)
IS0 11784:2010
EN NP IS0 11784-2-3-4:1996/Amd.2:2010(E)
BS IS0 11784-2-8-7:2010(E)
EN NP ISO 11784-5-120-78949-56-789:2010
EN DIN 11784-5:2019(B)";
RegexOptions options = RegexOptions.IgnoreCase | RegexOptions.Multiline;
Regex regex = new Regex(pattern, options);
string result = regex.Replace(input, substitution);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx