Sign In
Eric Gunnerson's Compendium
Tags
Agile
Avalon
Books
Column
CrackedRib
CSharp
Cycling
electronics
Friends
Fun
HealthVault
Humorish
Language
Pages
Photography
Program Manager
Programming
Regex 101
Review
Tutorial
Vista
What's Wrong With This Code
Windows DVD Maker
Windows Movie Maker
WPF
XNA
Browse by Tags
MSDN Blogs
>
Eric Gunnerson's Compendium
>
All Tags
>
regex 101
Tagged Content List
Blog Post:
MSDN Regular Expression Forum
Eric Gunnerson
There's now an MSDN Regular Expression Forum
on
1 Mar 2007
Blog Post:
Rule #1 of Regex debugging
Eric Gunnerson
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...
on
6 Jun 2006
Blog Post:
Regex 101 posts - continue or not?
Eric Gunnerson
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...
on
14 Mar 2006
Blog Post:
Regex 101 Answer I10 - Extract repeating hex blocks from a string
Eric Gunnerson
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...
on
14 Mar 2006
Blog Post:
Regex 101 Exercise I10 - Extract repeating hex blocks from a string
Eric Gunnerson
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”
on
6 Mar 2006
Blog Post:
Regex 101 Discussion I9 - Count the number of matches.
Eric Gunnerson
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...
on
6 Mar 2006
Blog Post:
Regex 101 Exercise I9 - Count the number of matches
Eric Gunnerson
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
on
28 Feb 2006
Blog Post:
Regex 101 Discussion I8 - replace space count with spaces
Eric Gunnerson
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...
on
28 Feb 2006
Blog Post:
Regex 101 Exercise I8 - replace space count with spaces
Eric Gunnerson
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
on
13 Feb 2006
Blog Post:
Regex 101 Discussion I7 - Make sure all characters inside <> are uppercase
Eric Gunnerson
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...
on
10 Feb 2006
Blog Post:
Regex 101 Exercise I7 - Make sure all characters inside <> are uppercase
Eric Gunnerson
Regex 101 Exercise I7 - Make sure all characters inside <> are uppercase
on
6 Feb 2006
Blog Post:
Regex 101 Discussion I6 - Remove font directives from HTML
Eric Gunnerson
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. ...
on
3 Feb 2006
Blog Post:
Regex 101 Exercise I6 - Remove font directives from HTML
Eric Gunnerson
Regex 101 Exercise I6 - Remove font directives from HTML Remove all <font…> or </font> directives from an HTML string.
on
30 Jan 2006
Blog Post:
Regex 101 Discussion I5 - Remove unapproved HTML tags from a string
Eric Gunnerson
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...
on
27 Jan 2006
Blog Post:
Regex 101 Exercise I5 - Remove unapproved HTML tags from a string
Eric Gunnerson
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.
on
23 Jan 2006
Blog Post:
Regex 101 Discussion I4 - remove unprintable characters from a string
Eric Gunnerson
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-...
on
23 Jan 2006
Blog Post:
Regex 101 Exercise I4 - remove unprintable characters from a string
Eric Gunnerson
Exercise I4 - remove unprintable characters from a string Given an input string, remove all characters that are not printable.
on
17 Jan 2006
Blog Post:
Regex 101 Answer I3 - Expand ranges in a string
Eric Gunnerson
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 ...
on
17 Jan 2006
Blog Post:
Regex 101 Exercise I3 - Expand ranges in a string
Eric Gunnerson
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
on
9 Jan 2006
Blog Post:
Regex 101 Discussion I2 - Find two words in a string
Eric Gunnerson
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...
on
16 Dec 2005
Blog Post:
Regex 101 Discussion I1 - Match a floating point number
Eric Gunnerson
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...
on
12 Dec 2005
Blog Post:
Regex 101 Exercise I2 - Find two words in a string
Eric Gunnerson
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...)
on
12 Dec 2005
Blog Post:
Regex 101 Exercise I1 - Match a floating point number
Eric Gunnerson
Regex 101 Exercise I1 - Match a floating point number Match a floating point number. Sample strings: You know what a floating point number is.
on
5 Dec 2005
Blog Post:
Regex 101 Discussion S6 - Change the extension on a file
Eric Gunnerson
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...
on
2 Dec 2005
Blog Post:
Regex 101 Exercise S6 - Change the extension on a file
Eric Gunnerson
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...
on
28 Nov 2005
Page 1 of 2 (34 items)
1
2