using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^<tr.*?>(?:<td>.*?<\/td>){2}<td>(.*?)<\/td><td>.*?<\/td><td>(.*?)<\/td>.*?<a href="".*?_(.*?)_(.*?)\.html.*$";
string substitution = @"$2;$1;$3\/$4";
string input = @"<tr><td><small>1</small></td><td>Kalisz</td><td>62-800</td><td>Poland</td><td>Greater Poland</td><td>Kalisz</td><td>Kalisz<tr><td></td><td colspan=6> <a href=""/maps/browse_51.75_18.087.html"" rel=""nofollow""><small>51.75/18.087</small></a></td></tr>
<tr class=""odd""><td><small>2</small></td><td>Piotrków Trybunalski</td><td>97-300</td><td>Poland</td><td>Łódź Voivodeship</td><td>Piotrków Trybunalski</td><td>Piotrków Trybunalski<tr class=""odd""><td></td><td colspan=6> <a href=""/maps/browse_51.411_19.689.html"" rel=""nofollow""><small>51.411/19.689</small></a></td></tr>
<tr><td><small>3</small></td><td>Toruń</td><td>87-100</td><td>Poland</td><td>Kujawsko-Pomorskie</td><td>Toruń</td><td>Toruń<tr><td></td><td colspan=6> <a href=""/maps/browse_53.021_18.623.html"" rel=""nofollow""><small>53.021/18.623</small></a></td></tr>";
RegexOptions options = 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