开发者

Remove trailing tags from a HTML textfield in PHP and/or TinyMCE

开发者 https://www.devze.com 2023-01-04 05:07 出处:网络
I have a problem: I am using TinyMCE for a text field. It all works fine until a user hits the enter button some times at the end of h开发者_开发技巧is input (new lines that are not needed). So for so

I have a problem: I am using TinyMCE for a text field. It all works fine until a user hits the enter button some times at the end of h开发者_开发技巧is input (new lines that are not needed). So for some inputs I save

<p>CONTENT</p><p> </p><p> </p>

or

<p>CONTENT</p><br /><br />

Since this input is displayed at other places of the webpage in a certain design, the trailing empty paragraphs and breaklines can trash the layout.

So I am looking for a way to check wheter these empty tags exists at the end of a string in PHP to remove them (for previously created entries) and if possible, I would like to configure TinyMCE to not allow such tags at all (not as important as the PHP solution).

Does anyone have an idea on how to do that? I can find/replace all empty paragraphs but this is too hard since users are using them to create gaps between their inputs. I really just want to find the trailing ones.


(<p> </p>|<br />)+$
0

精彩评论

暂无评论...
验证码 换一张
取 消