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

  • Автор темы Автор темы Perfecto
  • Дата начала Дата начала

Perfecto

Client
Регистрация
06.08.2013
Сообщения
108
Реакции
9
Баллы
18
Hi,

I'm trying to add a line break every time an HTML tag closes
Regex : </.*?>
 
You should use TextProcessing>Replace
and replace </.*?> with </.*?><br>
something like that
 
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
LrQtdTa.png

it won't replace by a regex but it will put the regex in text everywhere
 
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>
 
Последнее редактирование:
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# :
5kfyg1M.png
 

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