i trying write function determines if string contains html tags. following works fine:
self.containstags = ko.computed(function() { if(/<[a-z][\s\s]*>/i.test(self.response())) { return true; } else { return false; } }, self);
except, matches email addresses, eg. <test@mail.com>
, </test@mail.com>
. want search through string , if finds tag, return true unless email address above - continue searching through string , return true if finds actual html tag or false if doesn't.
here wrote, unfortunately doesn't work want to:
self.containstags = ko.computed(function() { if(/<[a-z][\s\s]((?!@).)*>/i.test(self.response())) { return true; } else { return false; } }, self);
whats regex ?
/<[^@<>]+>/i
Comments
Post a Comment