.Net Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - More.Net Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 5th, 2004, 02:54 PM
bigteejay bigteejay is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 5 bigteejay User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 46 sec
Reputation Power: 0
Need some help finishing up my Regular Expression pattern

Greetings,
I am trying to parse/validate some user-input for an app I am writing that merges several files into our master database.

The files are in the following storage format...
{drive}\{Misc Folders}\Cust{Customer Number}\{Season}{Year}\{Misc CSV file/table names}.CSV

For example...
p:\folder1\folder2\might_have_this_folder_too\CUST100\F00\ORDERS.CSV

I have the code to validate the drive (or \\server if used instead of drive letter or mapped drive), and the code for validating the customer folder on down through the path/tree, but I am having troubles accounting for the fact that this data might reside in any number of sub folders.

So essentially, if the user input is as such...
p:\CUST100\F00\ORDERS.CSV

My code would work great so far.

Here is an example of what I have so far...
^(?P<StorageResource>(?:[a-zA-Z]{1}|(?:\\{2}[a-zA-Z0-9-_ ]+))\\
CUST(?P<CustNumber>\d+)\\(?P<Season>[fswu]{1})(?P<Year>\d{2})\\
(?P<TableName>[a-zA-Z0-9-_ ]+\.csv$)

How can I account for either...
p:\CUST100\F00\ORDERS.CSV
or...
p:\who\knows\how\many\subfolders\CUST100\F00\ORDERS.CSV


Some explaination of what I have...
^(?P<StorageResource>(?:[a-zA-Z]{1}|(?:\\{2}[a-zA-Z0-9-_ ]+))\\ - This Searches for a single drive letter followed by a colon, or two slashes, and a computer name, and returns it as the named group "StorageResource"
CUST(?P<CustNumber>\d+)\\(?P<Season>[fswu]{1})(?P<Year>\d{2})\\ - This searches for the word "CUST" followed by a string of numbers, and returns it as the group named "CustNumber"
- Then searches for one of the 4 possible season codes, returns as "Season", and then searches for 2 digits, returned as the "Year" named group
(?P<TableName>[a-zA-Z0-9-_ ]+\.csv$) - This searches for some string of alphanumeric characters, ending in .csv, and specifies that this must be at the end of the string... as the named group "TableName"

I appreciate any help that could be offered.

Regards,
Tj

Reply With Quote
  #2  
Old January 5th, 2004, 06:11 PM
bigteejay bigteejay is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 5 bigteejay User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 46 sec
Reputation Power: 0
arrrrrrrrrrrggggggggggggggggggggg..........

another user on another board got me the answer... they found what I was trying to find (and nearly going bald in the process)....

All I needed was to add ".*" (any char 0 or more times) to my pattern to account for various subdirectories and such.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - More.Net Development > Need some help finishing up my Regular Expression pattern


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT