Verification email and URL
1. Match name
"/^[a-zA-Z]*$/"
Only spaces and letters are allowed, "^" means the beginning, "$" means the end, [a -zA-Z ] represents a character from a-z or A-Z or a space.
Example:
$name = test_input($_POST["name"]); if (!preg_match("/^[a-zA-Z ]*$/",$name )) { $nameErr = "Only letters and spaces allowed!"; }
2. Match E-mail
“/([\w-]+\@[\w-] +.[\w-]+)/”
“\w” matches any word character including an underscore. Equivalent to '[A-Za-z0-9_]';
+ Matches the previous subexpression one or more times;
"-" matches "-".
3. Match URL
“/\b(?:(?:https?|ftp):\/\/|www.)[-a-z0-9+&@ #\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i”
The red lines are all marked Regular expression.
Regular expression, also known as regular expression. (English: Regular Expression, often abbreviated as regex, regexp or RE in code), a concept in computer science. Regular tables are usually used to retrieve and replace text that matches a certain pattern (rule).
Regular expressions will be learned in the following advanced PHP tutorials. You can use them first when learning forms, just for understanding.
##