Here is an example of the text:

Каждый веб-разработчик знает, что такое текст-«рыба». Текст этот, несмотря на название, не имеет никакого отношения к обитателям водоемов. Используется он веб-дизайнерами для вставки на интернет-страницы и демонстрации внешнего вида контента, просмотра шрифтов, абзацев, отступов и т.д. <h3>Конечно, возникают некоторые вопросы.</h3> Самым известным «рыбным» текстом является знаменитый Lorem ipsum. Считается, что впервые его применили в книгопечатании еще в XVI веке. Своим появлением Lorem ipsum обязан древнеримскому философу Цицерону, ведь именно из его трактата «О пределах добра и зла» средневековый книгопечатник вырвал отдельные фразы и слова, получив текст-«рыбу», широко используемый и по сей день. И даже с языками, использующими латинский алфавит, могут возникнуть небольшие проблемы: в различных языках те или иные буквы встречаются с разной частотой, имеется разница в длине наиболее распространенных слов. 

I wrote this regular season:

 ^<h3>.*<\/h3>$ 

But she touches all the headings of level 3. If you add the symbol "!" To the beginning, then in general there will not be anything. Here is a link to regex101.

  • Do you have it just a piece of text as it is, or is it inside a certain html document? - teran
  • This is a piece of text as it is, it is not in any document. I pulled it all from XML. It was there. Now I need to wrap all the paragraphs in <p> ... </ p>. - LexXy
  • one
    Use XSLT to convert XML to HTML, and write there so that the text is enclosed in tags. - Wiktor Stribiżew
  • Never once encountered XSLT. It will be interesting to test)) - LexXy

1 answer 1

You can try the regular expression ^\s*([^<][^\r\n]+)$ - it selects all strings that do not begin with the < character, ignoring spaces at the beginning. Then it will be necessary only to replace the text, for example, with <p>$1</p> . $1 here is the first (indexing here comes from one) group "caught" by a regular expression in parentheses. Those. character string not starting with <

  • It worked. Only the last paragraph stood out incorrectly. Look here please. regex101.com/r/Dfk1kh/2 - LexXy
  • Try this: ^ \ s * ([^ <\ r \ n] +) $ - Jagon95