regex – 正则表达式来计算字符串中逗号的数量
发布时间:2020-12-14 06:35:58 所属栏目:百科 来源:网络整理
导读:如何构建一个正则表达式,匹配一个包含任何字符但必须包含21个逗号的任何长度的字符串? /^([^,]*,){21}[^,]*$/ 那是: ^ Start of string( Start of group[^,]* Any character except comma,zero or more times,A comma){21} End and repeat the group 21 t
如何构建一个正则表达式,匹配一个包含任何字符但必须包含21个逗号的任何长度的字符串?
/^([^,]*,){21}[^,]*$/ 那是: ^ Start of string ( Start of group [^,]* Any character except comma,zero or more times,A comma ){21} End and repeat the group 21 times [^,zero or more times again $ End of string (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |