I have been looking for a good way to add code to my blogs and Charles put me onto this. So this is what code looks like in the DotNetNuke blog when added with the Insert Code for Windows Live Writer plugin.
Bit of C#
1: static bool IsPhone(string s)
2: {
3: // TODO: Add regular expression matching
4: return Regex.IsMatch(s, @"^\(?\d{3}\)?[\s\-]?\d{3}\-?\d{4}$");
5: }
6:
7: static bool IsZip(string s)
8: {
9: // TODO: Add regular expression matching
10: return Regex.IsMatch(s, @"^\d{5}(\-\d{4})?$");
11: }
12:
13: static string ReformatPhone(string s)
14: {
15: var m = Regex.Match(s, @"^\(?(\d{3})\)?[\s\-]?(\d{3})\-?(\d{4})$");
16:
17: return String.Format("({0}) {1}-{2}",m.Groups[1], m.Groups[2], m.Groups[3]);
18: }
Nice isn’t it :)
And some VB..
1: Private Sub InitializeTree()
2: CategoryTree.IndentWidth = 10
3: CategoryTree.CollapsedNodeImage = ResolveUrl("~/images/max.gif")
4: CategoryTree.ExpandedNodeImage = ResolveUrl("~/images/min.gif")
5: CategoryTree.PopulateNodesFromClient = True
6: End Sub
Beautiful. Now to write some code worth bloggin’ about.