I have a CRUD maintenance screen with a custom rich text editor control (FCKEditor actually) and the program extracts the formatted text as HTML from the control for saving to the database. However, part of our standards is that leading and trailing whitespace needs to be stripped from the content before saving, so I have to remove extraneous and <br> and such from the beginning and end of the HTML string.
I can opt to either do it on the client side (using Javascript) or on the server side (using Java) Is there an easy way to do this, using regular expressions or something? I'm not sure how complex it needs to be, I need to be able to remove stuff like:
<p><br /> </p>
yet retain it if there's any kind of meaningful text in between. (Above snippet is from actual HTML data saved by the tester)
- You can buy me a coffee!
- Click here to post a comment!
- You can write a reply on your own site and submit the URL as a webmention via the form below.
- Or you can just contact me!
That should match all paragraphs that don't contain any "meaningful text".
It's probably best to do it on the server-side though.
via stackoverflow.com