I am looking for regex which returns false if it finds particular words anywhere in the paragraph in Java -


in our application allowing users write html scripts , don't want save script if contains particular words onmouseover, onclick etc.

e.g. if user enter script below regex should return false. if not contain words should allow user has entered.

<table border="0" cellpadding="0" cellspacing="0" width="100%"> <tbody>     <tr>         <td><b onclick="alert('wufff!')">click me!</b></td>         <td width="190"><b onmouseover="alert('wufff!')">click me!</b></td>      </tr> </tbody> 

i tried regex , did not work:

^(?=((?!onmouseover\s*=|onclick).)*$)(?=[\p{l}\p{p}\p{n}\p{so}\p{sc}\s+%26&=&amp%\\\-_|<>/]+)$ 

you can use alternatives check if unwelcome words appear in input text.

(?s)^((?!cellpadding|cellspacing|onmouseover).)*$ 

i guess question not parsing html, validating input in specific tool.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -