Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var testRegex = function (string) {
- var pattern1 = /<[^>]+>/ig;
- var pattern2 = /<img [^>]+>/ig;
- return (pattern1.test(string) && !pattern2.test(string));
- };
- console.log(testRegex("abc<a href='http://example.com'>Link</a>defg")); // true
- console.log(testRegex("abc<img src='example.jpg'>defg")); // false
- console.log(testRegex("abc<a href='http://example.com'>Link</a>de<div>kkk</div>\
- fg<img src='example.jpg'>")); // false
- console.log(testRegex("abcdefg")); // false
- console.log(testRegex("abc<img src='example.jpg'>defg<img src='example.jpg'><im\
- g src='example.jpg' width=25 height=25>")); // false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement