This article mainly introduces the example code of HTML using regular expressions to check tables. The code is simple and easy to understand, very good, and has reference value. Friends who need it can refer to it.
Let me share with you the HTML code. Example code of the regular expression check table. The specific code content is as follows:
正则表达式在JavaScript脚本中是很好用的检验语法规则的方法。但是与Java中的正则表达式有所不同。它需要在regex规则上以“^”开始,以"$"结束。
以下让我们看看一个实例。
Attachment: Some commonly used rules:
"^\\d+$" //Non-negative integer (positive integer + 0)
"^[0-9]*[1-9][0-9]*$" //Positive integer
"^((-\\d+)|(0+))$" //Non-positive integer (negative integer + 0)
"^-[0-9]* [1-9][0-9]*$" // Negative integer
"^-?\\d+$" // Integer
"^\ \d+(\\.\\d+)?$" //Non-negative floating point number (positive floating point number + 0)
"^(([0-9]+\\.[0 -9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0- 9]*[1-9][0-9]*))$" //Positive floating point number
"^((-\\d+(\\.\\d+)?) |(0+(\\.0+)?))$" //Non-positive floating point number (negative floating point number + 0)
"^(-(([0-9]+ \\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+) |([0-9]*[1-9][0-9]*)))$" //Negative floating point number
"^(-?\\d+)(\\ .\\d+)?$" //Floating point number
"^[A-Za-z]+$" //A string composed of 26 English letters
"^[A-Z]+$" //A string consisting of 26 uppercase English letters
"^[a-z]+$" //A string consisting of 26 lowercase English letters A string composed of
"^[A-Za-z0-9]+$" //A string composed of numbers and 26 English letters
" ^\\w+$" //A string consisting of numbers, 26 English letters or underscores
"^[\\w-]+(\\.[\\w-]+ )*@[\\w-]+(\\.[\\w-]+)+$" //email address
"^[a-zA-z]+:/ /(\\w+(-\\w+)*)(\\.(\\w+(-\\w+)*))*(\\?\\S*)?$" //url
The above is the detailed content of Using regular expressions to implement form validation in HTML. For more information, please follow other related articles on the PHP Chinese website!