using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"<(\S+) tag=""([^""]+)"">([^<]+)<\/(?1)>";
string substitution = @"<$1><$2>$3</$2></$1>";
string input = @"<image tag=""plan"">http://img.nmarket.pro/photo/pid/E2087273-BDC1-4717-9F2E-20F6A76E0479/?v=1&cid=2415&pid=E2087273-BDC1-4717-9F2E-20F6A76E0479&wpsid=51&hash=031b3173e71427e3673247f8a80135c8</image>
<image tag=""houseuncategorized"">http://img.nmarket.pro/photo/pid/1C372F09-3440-49FE-9A6D-048EF51B5F73/?v=1&cid=2415&pid=1C372F09-3440-49FE-9A6D-048EF51B5F73&wpsid=51&hash=810aea88a716dfff20ae5c182bf38888</image>
<image tag=""houseuncategorized"">http://img.nmarket.pro/photo/pid/3628BB57-3D4C-43A9-AD00-843E5D5F657F/?v=1&cid=2415&pid=3628BB57-3D4C-43A9-AD00-843E5D5F657F&wpsid=51&hash=abf93d04775994f55fe82eb84dfad54e</image>
<image tag=""houseuncategorized"">http://img.nmarket.pro/photo/pid/3EDBD70B-7393-4A93-9BAD-54B32DA49EEF/?v=1&cid=2415&pid=3EDBD70B-7393-4A93-9BAD-54B32DA49EEF&wpsid=51&hash=0565037ec9d45e15d0c84df34100e3dc</image>
<image tag=""houseuncategorized"">http://img.nmarket.pro/photo/pid/2C8FE09E-AE07-4E13-89F0-B4695A7428AF/?v=1&cid=2415&pid=2C8FE09E-AE07-4E13-89F0-B4695A7428AF&wpsid=51&hash=f1a03336866c285fb16a604708a9c15e</image>
<image tag=""housemain"">http://img.nmarket.pro/photo/pid/0CCFA7EA-3757-4740-A721-BF75DEAAB11C/?v=1&cid=2415&pid=0CCFA7EA-3757-4740-A721-BF75DEAAB11C&wpsid=51&hash=c69a5cf80cd48f6ccc4b68c077d5f301</image>
<image tag=""complexscheme"">http://img.nmarket.pro/photo/pid/29E51673-697F-4F38-9F9B-1DF28B22F3A1/?v=1&cid=2415&pid=29E51673-697F-4F38-9F9B-1DF28B22F3A1&wpsid=51&hash=c826f221b1d372d0defbc04c857f01f3</image>
<image tag=""floorplan"">http://img.nmarket.pro/photo/pid/F0DB967A-895F-4740-9FFE-FF3F100519EE/?v=1&cid=2415&pid=F0DB967A-895F-4740-9FFE-FF3F100519EE&wpsid=51&hash=15c82a24c7c0c6bacd8b1551c44ca0ec</image>
<parking tag=""hello"">world</class>
";
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