Contents tagged with Regex
-
RegexLib.com - recent additions
Just thought that I'd mention that RegexLib.com has received 10 new patterns this week. Here's a couple of interesting titbits:
-
Match opening tags improvements
I've made a couple of alterations to the opening tag regex.
-
HOW TO: Using RegexSnippets
I was just chatting to Thomas about RegexSnippets and how I use it to test my regex's. I think that most people haven't cottoned-on to the fact that you can write test modules within RegexSnippets itself. To use the code IDE do the following:
-
Regex to match opening Tags
While fiddling around in RegexSnippets tonight I concocted this regex to match opening tags and to capture the various elements:
-
RegexLib.com - Rss + Notifications!
For the 2nd time this week I've used the code in the recent Rss article on Msdn to write an Rss feed, this time it was to make available a feed of the latest Regex patterns that are added to the RegexLib.com site. I've added the little orange "Xml" link on the side menu and you can add the feed to your aggregator by pointing it to the following link:
-
RegexLib.com features added
I spent some time this weekend altering RegexLib.com to try and push more information to the "front" of the site. I've added a couple of repeaters to the Home page that show a listing of recent patterns and also the top 10 contributors. Clicking on a top contributor takes you to a page that shows all patterns submitted by that particular user. This is a new page and I'm hoping that it will make the site even more popular and further entice people to use RegexLib.com to store their own patterns.
-
Regex to capture an attribute collection
Wayne posted an elegant solution on the regex list today in answer to the following question: "How do I find all INPUT tags and pick out the attribute/values within them?". For the record, here's the pattern that Wayne came up with
... and here is some sample code that he provided for demonstrating its use (NOTE: the usage of the Captures on each Match'ed item):<input \s+ ( (?'Attr'\w+) \s* = \s* (?'Value' [^\s"'>]+ | "[^"]*" | '[^']*') \s* )* #match zero or more Attrs /?>
Regex rex = new Regex(@" <input \s+ ( (?'Attr'\w+) \s* = \s* (?'Value' [^\s""'>]+ | ""[^""]*"" | '[^']*') \s* )* #match zero or more Attrs /?>", RegexOptions.ExplicitCapture | RegexOptions.IgnorePatternWhitespace); foreach(Match m in rex.Matches( textToSearch )) { Console.WriteLine("Found a match with these attributes:"); for(int i=0; i < m.Groups["Attr"].Captures.Count; i++) { Console.WriteLine("Attr: " + m.Groups["Attr"].Captures[i].Value); Console.WriteLine("Value: " + m.Groups["Value"].Captures[i].Value); } Console.WriteLine(); }
-
RegexLib.com
Over the past 3 or 4 months I've been involved in adding some new features to RegexLib.com. Firstly, we changed the look-and-feel of the site (thanks to Thomas 'Aylar' Johansen) to give it a friendly look and to change the navigation structure.
-
My favourite online resource
My favourite list or newsgroup would have to be the Regex list over at ASPAlliance:
-
Regex Workbench V2
Today I discovered that Eric Gunnerson has been blogging! While browsing some of his older entries I noticed that he's recently updated the Regex WorkBench (with Examine-o-matic!):