且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

一个正则表达式,用于匹配带有字母数字,空格和标点符号的字符串

更新时间:2022-11-15 11:21:36

只需在类内(在方括号内)添加标点符号和其他字符:

Just add punctuation and other characters inside classes (inside the square brackets):

[A-Za-z0-9 _.,!"'/$]*

这匹配包含空格,_,字母数字,逗号,!,,$,...的每个字符串"添加一些特殊字符时请注意,也许您需要转义它们:更多信息在这里

This matches every string containing spaces, _, alphanumerics, commas, !, ", $, ... Pay attention while adding some special characters, maybe you need to escape them: more info here