## MSDN Regular Expression Forum

There’s now an MSDN Regular Expression Forum

## Rule #1 of Regex debugging

Rule #1 of Regex debugging The regex engine isn’t hung. It will finish eventually. However, “eventually” may not until after the heat death of the universe. You either didn’t anchor your string, or you didn’t think clearly about how the quantifiers “*” or “+” work. Or both…

## Regex 101 posts – continue or not?

I’ve been getting bored with the regex 101 exercises that I ‘ve been posting, as lots of them are simply variants of what I’ve posted in the past, and there’s not really much value to add in the discussion. I have 9 more of the exercises remaining. Things I could do: 1) Do all of…

## Regex 101 Answer I10 – Extract repeating hex blocks from a string

Regex 101 Exercise I10 – Extract repeating hex blocks from a stringGiven 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” ***** You can match the hex digits with: H'(?<Values>[0-9a-fA-F]{4}) Like our last example, you can call Match() multiple time, use Matches(), or do it in a single call with: (H'(?<Values>[0-9a-fA-F]{4})&)+

## Regex 101 Exercise I10 – Extract repeating hex blocks from a string

Regex 101 Exercise I10 – Extract repeating hex blocks from a stringGiven 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”

## Regex 101 Discussion I9 – Count the number of matches.

Regex 101 Exercise I9 – Count the number of matches Given a string like: # # 4 6 # # 7 # 45 # 43 # 65 56 2 # 4345 # # 23   Count how many numbers there are in this string —– There are a few ways to approach this problem. In…

## Regex 101 Exercise I9 – Count the number of matches

Regex 101 Exercise I9 – Count the number of matches Given a string like: # # 4 6 # # 7 # 45 # 43 # 65 56 2 # 4345 # # 23   Count how many numbers there are in this string

## Regex 101 Discussion I8 – replace space count with spaces

Exercise I8 – replace space count with spaces Given a string with embedded space counts: <15sp>Indented by 15 spaces Replace the <<count>sp> with <count> spaces. So, if you have <4sp>Text you should end up with     Text ******* This is fairly straightforward. First, we need to match the space count “thingy”. We’ll use: <?<Count>\d+)sp> And…

## Regex 101 Exercise I8 – replace space count with spaces

Exercise I8 – replace space count with spaces Given a string with embedded space counts: <15sp>Indented by 15 spaces Replace the <<count>sp> with <count> spaces. So, if you have <4sp>Text you should end up with     Text

## Regex 101 Discussion I7 – Make sure all characters inside <> are uppercase

Regex 101 Exercise I7 – Make sure all characters inside <> are uppercase First, as Sheva pointed out, making them all *lowercase* would make a lot more sense, but you have probably noticed that the correlation between these exercises and making sense is tenuous at best. This is another case where that MatchEvaluator functionality is…