I facing-out a problem when use Regexp for restrict to enter HTML entity into text-area.
I used this Regexp - /<(.|\n)*?>/g; for restrict HTML entity and it's work fine for me, but when i declare the global variable and used this regexp, It's give me different - different test cases(true/false) each time.
There is a Jsfiddle - Try This
when you click on "submit" button first time you get "true" and second time you get "false" for same content.
Can any one tell me why my regexp return different - different test cases each time when declare it globally?
Thank for your help...!!!
(.|\n)in your regexes; see this question for the reasons why. The traditional way to match anything-including-newlines in JavaScript is[\s\S], but you can usually do better than that. In this case you could use/<[^<>]+>/.