Tuesday, February 19, 2008

Regular Expression Negation for Required Field Validators

Out of the box ASP.NET regular expression validators have the following behavior:

Does control value match regular expression? If yes validation passes, else validation fails.

But what if you wanted the following:

Does control value NOT match regular expression? If yes validation passes, else validation fails.

Turns out there is no "If expression not match" property on a regular expression validator. Now, you can make your own custom regular expression control, or you can buy a toolset. But it turns out you might be able to do it in your regular expression itself.

This can be accomplished by using something called a Negative lookahead assertion. It succeeds if the contained expression doesn't match at the current position in the string.

The syntax is

(?!<value>)

For example, say you wanted to prevent users from using an email address that contained "@spam.com". You could use the following RegEx:

*@(?![Ss][Pp][Aa][Mm][.][Cc][Oo][Mm]$).*

Now your regular expression validator will pass if their value does NOT match the regular expression.

Regular Expression are extremely powerful, and I encourage everyone to learn about them. If you can master them, consider yourself a superhero.

Sunday, February 17, 2008

Visual Studio 2008 Tour and Install Party

This month (February 27, 2008 18:00) I'll be speaking at the Dayton .NET Developers Group about Visual Studio 2008 and .NET 3.5.

The official blub is:

Visual Studio 2008 and .NET 3.5 are soon to be released, after a very public and open beta process. We will run around the products, and discuss what the new features are. This will briefly cover VS, WCF, WF, C# and VB.NET features.

<RandomSideNote>
I'm actually filling in for Brian Prince, who was filling in for Jeff Blankenburg. Both of whom are very busy men. Being that I'm a single guy, with no kids, or pets I figured I could jump in and help out. People seemed to be excited about this upcoming meeting, I just couldn't let it be canceled.
</RandomSideNote>

Saturday, February 16, 2008

I'll be on the Source Control Panel on February 19, 2008 18:00

The Cincinnati User's Group (Cinnug) has asked me to be a part of the "Source Control Panel" they are having on Tuesday February 19, 2008 at 1800.

This meeting is different then those I've been in before. It's an open panel for group members to come and ask questions about VSS, TFS, Harvest, ClearCase, Vault and Subversion.

I'll be there primarily as a Subversion resource, but I'll try to fill in on VSS and TFS where I can.

Short notice I know, but if you're not doing anything Tuesday, come on down an heckle me. I think it's going to be a lot of fun.

Central Ohio Day of .NET - April 19, 2008

CentralOhioDoDNLogo_smallIt's that time again. Time for us developers to get together and geek out to the latest technology and see who's smarter. ;)

Day of .NET events are a series of mini-conferences organized by developers for developers. The event it FREE to to all.

Visit the event's homepage, and register today.

For those that have attended the Dayton Cincinnati Code Camps  of the past, this year we've included the Columbus .NET user group as well. Because "The Central Ohio Dayton Cincinnati Code Camp" was just to much to say, and CODCCC had just too many C's. The name has been changed to "Central Ohio Day of .NET", or CODODN. Ah, just better.

But seriously, becoming part of the Day of .NET events makes it easier for coders to find us, and helps coders find similar events going on in their areas.

CentralOhioDoDNBadge Though the name may be different, it's the same great event. So come, meet new people, share ideas, socialize, and maybe learn something too.

Wednesday, February 13, 2008

Getting a list of .NET exceptions with Resharper.

Often I'm programming C#.NET and want to throw an exception but I don't know what exception to throw. I think "wouldn't it be nice if there was an easy way to get a list of the exceptions in .NET?"

I've Googled, I've dug thru the MDSN, then it hit me...

DUH! Resharper's intellisense.

A simple "throw new" gives you:

2008-02-14_1858

 

And you can use the "Navigate from here to Base" feature to get a more detailed list.

Just type "System.Exception" and hit the Resharper 2.x shortcut: Ctrl + Alt + B

Navigate_To_Base

Tuesday, February 5, 2008

Parsing a URI / URL in C# and VB.NET

I used to spend time parsing a URL string using old fashion .NET string methods. (Contains, Split, Substring, IndexOf, etc). I always thought, "There must be a better way to do this."

And there is, there is a tool in the .NET Framework to help you parse a fully qualified URI path.

System.UriBuilder

A few simple lines of code

2008-02-06_0508

Does a lot of the work for us.

2008-02-06_0507 

And this is just one of the Uri tools. I encourage you to look at the others as well.

  • System.Uri
  • System.UriComponents
  • System.UriFormat
  • System.UriHostNameType
  • System.UriIdnScope
  • System.UriKind
  • System.UriParser
  • System.UriPartial
  • System.UriTypeConverter

Wednesday, December 19, 2007

Twitter & Pidgin

What is Twitter?

Twitter is a tool designed to answer one question "What are you doing?" Some call it "micro blogging" or "blogging for the ADD," but I like to think of it as a global chat. It's a way for you to keep up with others, get to know people, and expand your network.

The concept is:

  • You sign up.
  • You follow people and read their "tweets" (a message on Twitter).
  • People follow you and read your tweets.

What is Pidgin?

Pidgin, formerly known as "Gaim", is a multi-protocol Instant Messaging client that allows you to use all of your IM accounts at once.

For example, if you have a GTalk account, you can use Pidgin as you IM client.

<Random side story>
For a long time I used Trillian and my multi-protocol IMer but certain features you have to pay for, like XMPP. At the same time I was looking for a portable IM'er (I'm a portable app
nut, but that's for another post). Then I came across Pidgin Portable and I was sold. (Later "Unofficial" versions can be located at Vane Parole)
</ Random side story>

Where the two shall meet!

In Twitter under "Settings > Phone & IM"

Twitter can send tweets to three IM account types that support XMPP (GTalk, LiveJournal, Jabber).

A couple of pitfalls.

Twitter only allows 140 characters on each tweet. Pidgin, out of the box, doesn't count characters. However, you can add the Character Counting plug-in.

If you have an away message up, and you get a tweet, Pidgin will auto tweet back with your away message.

Final Thoughts

I think the combination is quite nice. There are richer Twitter clients out there, but for what I need Pidgin serves me well.

Come children, follow me into a brave new world of communication, and addiction.