1

i got an Problem, i translating some stuff trought the Bing Translator API. The Text also contains HTML Tags in the most strings, my problem is that Bing add Blanks between HTML Tags, so i get a text like this:

Desculpe, nós não poderíamos encontrar um produto combinando sua solicitação de pesquisa. < br / >< forte > tente novamente? < / strong >

So my Question is: How can i remove the Whitespaces from the HTML Tags? I tried it with php's preg_ functions, but nothing what i done solved my problem, hope for your help guys.

4

1 回答 1

1

如果只有单个空格“破坏”您的 html,请尝试以下操作:

$text = str_replace(["< / ","< "], ["</", "<"], $text);
$text = str_replace([" / >", " >"], ["/>", ">"], $text);

但也许有一个更灵活的正则表达式解决方案......

于 2014-12-10T14:42:38.410 回答