且构网

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

JavaScript正则表达式:非数字字符

更新时间:2023-02-19 09:25:40

您要 [\ D] [^ \ d] ,但不需要 [^ \ D] .正则表达式区分大小写, \ d 匹配数字,而 \ D 匹配除数字之外的任何内容.

You want [\D] or [^\d], but not [^\D]. Regex is case-sensitive, \d matches a digit, and \D matches anything but a digit.