Home >Backend Development >PHP Tutorial >Implement 17 kinds of regular expressions in php, 17 kinds of regular expressions in php_PHP tutorial
17 kinds of regular expressions are implemented in php
This tutorial comes from: php tutorial website: http://php.662p.com
"^\d+[ DISCUZ_CODE_1 ]quot; //非负整数(正整数 + 0) "^[0-9]*[1-9][0-9]*[ DISCUZ_CODE_1 ]quot; //正整数 "^((-\d+)|(0+))[ DISCUZ_CODE_1 ]quot; //非正整数(负整数 + 0) "^-[0-9]*[1-9][0-9]*[ DISCUZ_CODE_1 ]quot; //负整数 "^-?\d+[ DISCUZ_CODE_1 ]quot; //整数 "^\d+(\.\d+)?[ DISCUZ_CODE_1 ]quot; //非负浮点数(正浮点数 + 0) "^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))[ DISCUZ_CODE_1 ]quot; //正浮点数 "^((-\d+(\.\d+)?)|(0+(\.0+)?))[ DISCUZ_CODE_1 ]quot; //非正浮点数(负浮点数 + 0) "^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))[ DISCUZ_CODE_1 ]quot; //负浮点数 "^(-?\d+)(\.\d+)?[ DISCUZ_CODE_1 ]quot; //浮点数 "^[A-Za-z]+[ DISCUZ_CODE_1 ]quot; //由26个英文字母组成的字符串 "^[A-Z]+[ DISCUZ_CODE_1 ]quot; //由26个英文字母的大写组成的字符串 "^[a-z]+[ DISCUZ_CODE_1 ]quot; //由26个英文字母的小写组成的字符串 "^[A-Za-z0-9]+[ DISCUZ_CODE_1 ]quot; //由数字和26个英文字母组成的字符串 "^\w+[ DISCUZ_CODE_1 ]quot; //由数字、26个英文字母或者下划线组成的字符串 "^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+[ DISCUZ_CODE_1 ]quot; //email地址 "^[a-zA-z]+://(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?[ DISCUZ_CODE_1 ]quot; //url
Detailed description: http://php.662p.com/thread-532-1-1.html