I have a form with a text editor(quill) where I am applying $sanitize to secure any code injection.
And after I am applying the following regex
string_regex = /[\n\r,.:?!()\]\[]|<\/?[^>]+(>|$)/
It removes all the html tags(e.g.: style of the html: Bold, Italic) and other especial characters
But I have some problems because
I want also receive html code as text, so I would like to maintain "(" "[", etc..
At the same time I want to remove these characters of "normal" words. E.g: Michael; (John) Brian! => Michael, John, Brian
I want to receive some characters with accents (é, ó, ú, etc...) that are codified by the sanitize as "& #2 3 3 ;" , so I need the " ; ". For these I am using HtmlDecode to show in the view.
There is any easy way to specify the regex for that?
Or at least maintain the ";" for words that starts with "&" and remove for the others
EDIT
As example if I have the string below:
<script>alert()</script> <p>wow</p> vocé John; Michael!
And I want to receive
<script>alert()</script> wow vocé John Michael