Applying Regular Expression (Regex) Validation to HTML Textbox Input Explained in Malayalam.
Regex Pattern Examples:
Email: pattern="[a-z0-9._+-]+@[a-z0-9]+\.[a-z]{2,}"
Phone: pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}"
Date: pattern="\d{1,2}-\d{1,2}-\d{4}"
pattern="c.t" - any single character including number (eg. cat, cot will match)
pattern="c[o|a]t" - cot or cat will match
pattern="colou?r" - it can be with u or without u (? means char is optional)
- one or more, * is zero or more
pattern="^\w{2,10}\s{1,}\w{2,}" - two words with a space char in between