使用VBA在Excel单元格中允许不超过21个字符的正则表达式 [英] Regular Expression to allow no more or less than 21 characters in excel cell using VBA

查看:144
本文介绍了使用VBA在Excel单元格中允许不超过21个字符的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想使用vba验证在excel工作表单元格中输入的字符.我正在尝试使用模式"^ [a-zA-Z0-9] {21,21} $".我希望它精确匹配21个字符(可以是字母数字),且不超过此数目.当字符少于21个字符时,它可以正常工作,但是当字符超过21个字符时,它不能正常工作.请建议我该如何实现.

感谢您的帮助.

在此先感谢,
Sunny K

Hi,

I want to verify the characters entered in excel sheet'' cell using vba. I''m trying this with the pattern "^[a-zA-Z0-9]{21,21}$". I want this to match exactly 21 characters (can be alphanumeric) and no more or less than that. Its working fine when the characters are less than 21 characters but not when they exceed. Please suggest me how could I achieve that.

I appreciate any help.

Thanks in Advance,
Sunny K

推荐答案

.我希望它能够精确匹配21个字符(可以是字母数字),且不超过此字符.当字符较少时,它可以正常工作不能超过21个字符,但不能超过21个字符.请建议我该如何实现.

感谢您的帮助.

在此先感谢,
Sunny K
". I want this to match exactly 21 characters (can be alphanumeric) and no more or less than that. Its working fine when the characters are less than 21 characters but not when they exceed. Please suggest me how could I achieve that.

I appreciate any help.

Thanks in Advance,
Sunny K


我尚未对其进行测试,但仅尝试一次指定21,如下所示:

I haven''t tested it, but trying specifying 21 just once, like so:

^[a-zA-Z0-9]{21}



这篇关于使用VBA在Excel单元格中允许不超过21个字符的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆