这很简单,但我无法弄清楚。我想用这个正则表达式找到一个子字符串。它将匹配“M4N 3M5”,但与以下内容不匹配:
const string text = "asdf M4N 3M5 adsf";
Regex regex = new Regex(@"^[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1} *\d{1}[A-Z]{1}\d{1}$", RegexOptions.None);
Match match = regex.Match(text);
string value = match.Value;