Regex 101 Exercise I10 - Extract repeating hex blocks from a string

Given the string:

PCORR:BLOCK=V5CCH,IA=H'22EF&H'2354&H'4BD4&H'4C4B&H'4D52&H'4DC9;

Extract all the hex numbers in the form “H’xxxx”

----------------------------------------------------------------------------------------------

Answer:

Regex regex = new Regex(@"(?<HexBlocks>H'[A-F_0-9]{4})", RegexOptions.IgnoreCase);
String inputString 
= @"PCORR:BLOCK=V5CCH,IA=H'22EF&H'2354&H'4BD4&H'4C4B&H'4D52&H'4DC9;";
MatchCollection matches 
= regex.Matches(inputString);
foreach (Match match in matches)
{
    Console.Write("{0} ", match.Value);
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-21
  • 2021-10-28
  • 2022-01-27
  • 2022-01-12
  • 2021-07-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
  • 2021-06-18
相关资源
相似解决方案