Browse by Tags

Tagged Content List
• Blog Post: MSDN Regular Expression Forum

There's now an MSDN Regular Expression Forum
• Blog Post: 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...
• Blog Post: 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 the remaining...
• Blog Post: Regex 101 Answer I10 - Extract repeating hex blocks from a string

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” ***** You can match the hex digits with: H'(?<Values>[0-9a-fA...
• Blog Post: Regex 101 Exercise I10 - Extract repeating hex blocks from a string

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”
• Blog Post: 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 all of them, we need a way to capture the numeric parts...
• Blog Post: 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
• Blog Post: 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...
• Blog Post: 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
• Blog Post: 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...
• Blog Post: Regex 101 Exercise I7 - Make sure all characters inside <> are uppercase

Regex 101 Exercise I7 - Make sure all characters inside <> are uppercase
• Blog Post: Regex 101 Discussion I6 - Remove font directives from HTML

Regex 101 Exercise I6 - Remove font directives from HTML Remove all <font…> or </font> directives from an HTML string. ***** I've decided to start linking my answers back to the original posts, since the answers given there are often as good or better than the one that I give. ...
• Blog Post: Regex 101 Exercise I6 - Remove font directives from HTML

Regex 101 Exercise I6 - Remove font directives from HTML Remove all <font…> or </font> directives from an HTML string.
• Blog Post: Regex 101 Discussion I5 - Remove unapproved HTML tags from a string

When accepting HTML input from a user, allow the following tags: <b> </b> <a href=…> </a> <i> </i> <u> </u> and remove any others. ****** My first comment is that you should be very careful when you do this sort of thing...
• Blog Post: Regex 101 Exercise I5 - Remove unapproved HTML tags from a string

Regex 101 Exercise I5 - Remove unapproved HTML tags from a string When accepting HTML input from a user, allow the following tags: <b> </b> <a href=…> </a> <i> </i> <u> </u> and remove any others.
• Blog Post: Regex 101 Discussion I4 - remove unprintable characters from a string

Exercise I4 - remove unprintable characters from a string Given an input string, remove all characters that are not printable. -------------- Assuming ASCII - or something like ASCII - non-printing characters have ascii values of 31 or lower. You can match them with the following: [\x01-...
• Blog Post: Regex 101 Exercise I4 - remove unprintable characters from a string

Exercise I4 - remove unprintable characters from a string Given an input string, remove all characters that are not printable.
• Blog Post: Regex 101 Answer I3 - Expand ranges in a string

Sorry about the lateness of this one. I had a meeting on Friday afternoon, and then had some things to take care of today. So anyway... I3 - Expand ranges in a string Given a string like: 1,2,4,6-9,12,15-17,20 expand the ranges, so the final string is: 1,2,4,6,7,8,9,12,15,16,17,20 ...
• Blog Post: Regex 101 Exercise I3 - Expand ranges in a string

I3 - Expand ranges in a string Given a string like: 1,2,4,6-9,12,15-17,20 expand the ranges, so the final string is: 1,2,4,6,7,8,9,12,15,16,17,20
• Blog Post: Regex 101 Discussion I2 - Find two words in a string

I2 - Find two words in a string Find any string that has the following two words in it: “dog” and “vet” ****** This is an interesting one, since it's not something that regex is particularly suited for. The test strings that I'm using are: I took my dog to the vet The vet fixed my dog My dog...
• Blog Post: Regex 101 Discussion I1 - Match a floating point number

Match a floating point number. [Update: Fixed a cut/paste issue with the match for + and -. Many of the comments on the original post spoke of not having sufficient sample strings. I omitted them deliberately, so that the problem requires a bit more work and will, with any luck, be more educational...
• Blog Post: Regex 101 Exercise I2 - Find two words in a string

I2 - Find two words in a string Find any string that has the following two words in it: “dog” and “vet” (yes, I know, I didn't get last week's discussion out there. It will be there shortly...)
• Blog Post: Regex 101 Exercise I1 - Match a floating point number

Regex 101 Exercise I1 - Match a floating point number Match a floating point number. Sample strings: You know what a floating point number is.
• Blog Post: Regex 101 Discussion S6 - Change the extension on a file

Regex 101 Exercise S6 - Change the extension on a file Given a filename including path, change the extension to .out. Input string example: C:\utility\Processor.cs ***** I said in the exercise description that this take a bit of care. One first blush (what a weird turn of phrase), one...
• Blog Post: Regex 101 Exercise S6 - Change the extension on a file

Regex 101 Exercise S6 - Change the extension on a file Given a filename including path, change the extension to .out. Input string example: C:\utility\Processor.cs Notes: The best answer to this is really to use System.IO.Path.ChangeExtension(), but that wouldn't be much of a Regex...
Page 1 of 2 (34 items) 12