星期二, 11月 08, 2005

[.Net]Regex 101 Exercise

Today, I found an article - Eric Gunnerson's C# Compendium : Regex 101 Exercise S3 - Validate a zip+4 zip code.

I think that I can practice my regular expression skill.

How to match these patterns using .Net regular expression??
98008
98008-4893

My answer is:
[0-9][0-9][0-9][0-9][0-9]-?[0-9]*

It seems stupid. There should be better solution.

沒有留言: