How to add a line break to each HTML tag closure?

Perfecto

Client
Регистрация
06.08.2013
Сообщения
94
Благодарностей
4
Баллы
8
Hi,

I'm trying to add a line break every time an HTML tag closes
Regex : </.*?>
 

VladZen

Administrator
Команда форума
Регистрация
05.11.2014
Сообщения
22 241
Благодарностей
5 847
Баллы
113
You should use TextProcessing>Replace
and replace </.*?> with </.*?><br>
something like that
 

Perfecto

Client
Регистрация
06.08.2013
Сообщения
94
Благодарностей
4
Баллы
8
Thanks for your answer but I just want a line break in the code not a br tag

And if use Text Processing>Replace like this

it won't replace by a regex but it will put the regex in text everywhere
 

BAZAg

Client
Регистрация
08.11.2015
Сообщения
1 764
Благодарностей
2 407
Баллы
113
Hi,

I'm trying to add a line break every time an HTML tag closes
Regex : </.*?>
C#:
string text = "<p>test</p><p>test</p><p>test</p><p>test</p><p>test</p>";

foreach(string s in Regex.Matches(text, @"</.*?>").Cast<Match>().Select(s => s.Value).Distinct()){
    text = text.Replace(s, string.Format("{0}{1}",s,Environment.NewLine));
    // text = text.Replace(s, string.Join(string.Empty,new[]{s,Environment.NewLine})); // or
    // text = text.Replace(s, s+Environment.NewLine); // or
}
return text;
out:
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
 
Последнее редактирование:

Perfecto

Client
Регистрация
06.08.2013
Сообщения
94
Благодарностей
4
Баллы
8
Thank you for taking the time to help me.
If someone has the same problem here is the syntax to integrate a variable in C# :
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)