/ Published in: PHP
This is an regular expression to match an HTML Tag from a given input.
Expand |
Embed | Plain Text
/^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$/ To use this expression follow the code below. //Save the expression in a variable. $correct_htmltag_format = "/^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$/"; //some input from a user through a text field or from a server. $user_input = $_REQUEST['html_tag']; //match the two input's and save it in a variable. //Condition goes here. if(tag_match){ echo "Correct HTML Tag"; } else{ echo "Incorrect HTML Tag"; }
Comments
Subscribe to comments
You need to login to post a comment.

does not work for me with "http://tr.wikipedia.org/wiki/S"
does not work for me with: 'http://tr.wikipedia.org/wiki/S'