I
I
igor11122018-09-01 04:36:34
JavaScript
igor1112, 2018-09-01 04:36:34

How to remove spaces in closing tags?

I'm using google translator api in node.js. And after a line break, the result is the following -<p>Hello, my name is <strong>Igor</strong></p>

<p> Здравствуйте, меня зовут <strong> Игорь </ strong> </ p>
Spaces appear in the closing tags, which makes the html invalid. Also, unwanted spaces appear between the word and the tag. How to remove those unnecessary spaces?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2018-09-01
@igor1112

No regulars. Just If suddenly there are several spaces, which is unlikely, then reg

$s = preg_replace('/<\/(\s+)(\w/)/gs', '</$2', $s);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question