我做了这个正则表达式:
^[a-zA-Z0-9_.-]*$
Run Code Online (Sandbox Code Playgroud)
支持:
letters [uppercase and lowercase]
numbers [from 0 to 9]
underscores [_]
dots [.]
hyphens [-]
Run Code Online (Sandbox Code Playgroud)
现在,我想添加以下内容:
spaces [ ]
comma [,]
exclamation mark [!]
parenthesis [()]
plus [+]
equal [=]
apostrophe [']
double quotation mark ["]
at [@]
dollar [$]
percent [%]
asterisk [*]
Run Code Online (Sandbox Code Playgroud)
例如,此代码仅接受上面的一些符号:
^[a-zA-Z0-9 _.,-!()+=“”„@"$#%*]*$
Run Code Online (Sandbox Code Playgroud)
返回:
警告:preg_match():编译失败:偏移量为16的字符类中的范围乱序