正则表达式匹配 4 组字母/数字,用连字符分隔 [英] Regex to match 4 groups of letters/numbers, separated by hyphens
问题描述
我需要一个匹配此模式的正则表达式(大小写无关紧要):
I need a regular expression that will match this pattern (case doesn't matter):
066B-E77B-CE41-4279
066B-E77B-CE41-4279
4 组字母或数字,每组 4 个字符,每组之间有连字符.
4 groups of letters or numbers 4 characters long per group, hyphens in between each group.
任何帮助将不胜感激.
推荐答案
数据样本如此之少,要确定您真正想要什么并不容易.
With such a small sample of data, it's not easy to be certain what you actually want.
我将假设该字符串中的所有字符都是十六进制数字,这就是您需要搜索的内容.
I'm going to assume that all the characters in that string are hex digits, and that's what you need to search for.
在这种情况下,您需要一个类似这样的正则表达式:
In that case, you would need a regular expression something like this:
^[a-f0-9]-[a-f0-9]-[a-f0-9]-[a-f0-9]$
如果它们可以是任何字母,那么用z
s替换f
s.
If they can be any letter, then replace the f
s with z
s.
哦,使用 myRE.IgnoreCase = True
使其不区分大小写.
Oh, and use myRE.IgnoreCase = True
to make it case insensitive.
如果您需要有关正则表达式的进一步建议,我建议您使用 http://www.regular-expressions.info/ 作为好网站.他们甚至有一个VB.net 特定页面.
If you need further advice on regular expressions, I'd recommend http://www.regular-expressions.info/ as good site. They even have a VB.net-specific page.
这篇关于正则表达式匹配 4 组字母/数字,用连字符分隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!