Regular Expression option for 3 or less characters

I have a regular expression below that works for a string example like:

  • MCCOY 3H L24 FINAL 02-28-2012.dwg or
  • SMITH-JOHNSON 5H R32 FINAL 05-26-2012.dwg

But now I'm trying to figure out how to change the regular expression to work for the examples above if they were like:

  • MCCOY 3H L-ABC FINAL 02-28-2012.dwg or
  • SMITH-JOHNSON 5H R-123 FINAL 05-26-2012.dwg

They can also be like

  • MCCOY 3H L-C2 FINAL 02-28-2012.dwg or
  • SMITH-JOHNSON 5H R-2 FINAL 05-26-2012.dwg

So to sum this up, that middle section will always have a Alphabetic character followed by a Dash and then it could have as much as 3 numbers or alphabetic characters or as few as 1 number or alphabetic character.

"^[a-z]+(?:[ -][a-z]+)*\s+\d+[a-z]\s+[a-z]\d+\s+[a-z]+\s+\d{2}-\d{2}-\d{4}\.dwg$"

Answers


\w{1,3}

matches 1 to 3 alphanumeric characters.

http://msdn.microsoft.com/en-us/library/az24scfc.aspx#quantifiers


Need Your Help

exporting an SSRS report to Excel failure

reporting-services ssrs-2008

When trying to export an SSRS report to excel, I am getting a runtime error. I have looked at the logs and see the following:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.