php - iframe Regular Expression form validation -
i'm having trouble validating form entry using regular expression. learning regular expressions , task.
the problem: have attempted write regex match soundcloud iframe. however, form entry accepted whether entry soundcloud iframe or not. appreciated!
this function came with:
function iframe_match ($iframe){ return(preg_match('#/<iframe width="100%" height="450" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/\?url=http%3a%2f%2fapi.soundcloud.com%2f|[a-z]|%|[0-9]| [f]|">\</iframe\>/#', $iframe)) ? true : false; }
and specific form check:
else if (iframe_match($_post['track_file1']) === false){ echo '<br/><br/><font color="red"><strong>must include iframe</strong><font>'; }
function iframe_match ($iframe){ return(preg_match('/<iframe[^>]*src="https:\/\/w.soundcloud.com\/player\/[^"]+">\s*<\/iframe>/',$iframe)) ? true : false; }
Comments
Post a Comment