Check if source contains a valid IFRAME code
Posted on August 22, 2019
This is the regular expression I use to be sure if an arbitrary mark-up is an actual valid iframe
code or not:
let someMarkupCode = '...'
let re = /<iframe [.\s\S]*<\/\s*?iframe>/gim
let check = someMarkupCode.match(re)
if (check && check.length > 0) {
console.log('is an IFRAME')
} else {
console.log('is not!')
}
That's it!