vendredi 29 mai 2015

How to filter   in textarea with regex?

btw: i know that using regex is not the best idea in the world...

For example i have such input variants:

<p>&nbsp; &nbsp; &nbsp;</p>

or

<p>&nbsp; &nbsp;</p>

or

<p>&nbsp;</p>

and i want to check my input like: all except <p> with &nbsp; in every amount of them (0, 1 or 50)...

i wrote such expression:

/[^<p>(\s*&nbsp;\s*)*<\/p>]/ig

and seems that it works, but!

for example i have such input:

<p>&nbsp; &nbsp;t&nbsp;</p>

or

<p>&nbsp; &nbsp;tttt&nbsp;tttt</p>

and it is thinking, that it is equal to my regex...

not a good idea...

what i do wrong in my regex? or maybe there are some better ways of solving this?

Aucun commentaire:

Enregistrer un commentaire