DeveloperBarn Forums

Go Back   DeveloperBarn Forums > Programming & Scripting > .Net Development

Discuss "Regular Expressions in C#..." in the .Net Development forum.

.Net Development - Learn about the Microsoft.Net framework and how to create powerful web-based (ASP.net) and client-based (Windows Forms) applications utilizing various languages such as C#, VB.Net, J# and others.


Closed Thread « Previous Thread | Next Thread »  
 
LinkBack (1) Thread Tools Display Modes
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old April 18th, 2008, 08:27 PM
Lauramc's Avatar
I like Data Cubes too...

 
Join Date: Mar 2008
Location: Far Far Away
Posts: 35
Thanks: 1
Thanked 1 Time in 1 Post
Rep Power: 1
Lauramc is on a distinguished road

Awards Showcase
Microsoft SQL Server 
Total Awards: 1

Default Regular Expressions in C#...

Bear with me, I have been out of the .Net loop for awhile. I have a need to use a regular expression and I could use some help crafting it. The expression needs to search an input string for a substring in the following format: #AA### where # is a number and A is a letter. The string will always be 6 characters long. The matching string should be returned, and this data will be added to a database.

Does anyone have an example of how this might be written?

Thanks!
Sponsored Links
  #2 (permalink)  
Old April 18th, 2008, 10:29 PM
lewy's Avatar
Dark Sonic Master

 
Join Date: Mar 2008
Location: Edinburg, TX
Posts: 34
Thanks: 0
Thanked 3 Times in 3 Posts
Rep Power: 1
lewy is on a distinguished road
Default

You can use the following expression: ^\d{1}[A]{2}\d{3}$

You can use it like this C# code sample:
Code:
if (Regex.IsMatch(YourInputString, "^\\d{1}[A]{2}\\d{3}$"))
    Response.Write("pass");
else
    Response.Write("fail");
__________________
................... ASCII and ye shall receive ..................
Knowledge is the only resource on earth that multiplies when shared

If you found a post helpful, please click the 'Thanks' button in the lower right-hand corner of the post.
  #3 (permalink)  
Old April 21st, 2008, 11:54 AM
Lauramc's Avatar
I like Data Cubes too...

 
Join Date: Mar 2008
Location: Far Far Away
Posts: 35
Thanks: 1
Thanked 1 Time in 1 Post
Rep Power: 1
Lauramc is on a distinguished road

Awards Showcase
Microsoft SQL Server 
Total Awards: 1

Default

Thanks I will give that a try today
Closed Thread

  DeveloperBarn Forums > Programming & Scripting > .Net Development

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Common Regular Expressions jmurrayhead .Net Development 0 April 21st, 2008 11:34 AM

LinkBacks (?)
LinkBack to this Thread: http://www.developerbarn.com/net-development/137-regular-expressions-c.html
Posted By For Type Date
Regular Expressions in C#... - .Net Development This thread Refback April 19th, 2008 07:49 PM


Sponsored Links

ASP.NET Resource Index
a directory of ASP.NET tutorials, applications, scripts, assemblies and articles for the novice to professional developer.

Free Web Directory
Including Chats and Forums Resources, Offer automatic, instant and free directory submissions.
URLZ Web Directory
URLZ Web Directory

Free Web Directory - Add Your Link
The Little Web Directory
Free Web Directory
Pegasus free web directory is a free directory organised by categories.

Web Directory & SEO Services
dirroot web directory


All times are GMT -4. The time now is 07:41 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
Copyright © 2008 DeveloperBarn.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46