Re: Help With Regular Expression (Another Post)

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Odawg" <odawg@xxxxxxxxxxxxxxxx> wrote in message
news:4ee1f21gneeloim5daslsimi13bbdoccp4@xxxxxxxxxx
I guess I did not explain my delima correctly in my original post. I
will try to be more cleaer.

I am trying to extract from a working a path, the state in which the
documents are retrived. Al of our files are stored or saved our
network share under the each of the states that we are assigned. an
Example of the working path are as followed:

Example paths:
'------------------
\server\share\folder\subfolder1\subfolder2\Texas\data\files\
\server\share\folder\subfolder1\subfolder2\subfolder3\Florida\data\fiels\
\server\share\folder\subfolder1\Ohio\subfolder2\WIP\data\files\
\server\share\folder\subfolder1\subfolder2\subfolder3\Maine\WIP\data\files\

Notice the states in each example (Texas, Ohio, Florida, and Maine)
When one of our analyst grabs a file from one of the working paths
above, we need to log which state he pulls those files from so that we
can keep metrics on the numbe of files we access from each state.

How can I extract the State from the path and set that to a variable.

I was thinking that we could possibly use a Select case statement but
I am only a novice and do not know how to do that.




IF s="Texas" then
state=Texas
Elseif s="Ohio" then
state=Ohio
Elseif s="Florida" Then
state="Florida"
Elseif s="Main" Then
state=Main
End IF


Any and all help in this matter is greatly appreciated




Not sure whether you need to use Regular Expressions here. One way to
extract state in this case is to have a list of all possible states in the
form of array or collection. Then you could use something like this:

'assume that marStates is module level array of strings (or collection)
defined and populated somewhere else
'if function returns an empty string then it means that no applicable state
is found in given string
function StateFromFile(sFileFullName as String) as String
dim vState as Variant
for each vState in marStates
if instr(1, sFileFullName , "\" & vState & "\", vbTextCompare) then
StateFromFile=vState
exit function
end if
next vState
end function


I don't know what do you want to do in your last example. Particularly, what
is
state=Texas.

It is only possible if identifiers, like Texas, are enumerations and in this
case you do need to use Select case but still not sure what you are trying
to accomplish - more details are needed.

Dmitriy.


.



Relevant Pages

  • Re: Help With Regular Expression (Another Post)
    ... Example of the working path are as followed: ... Elseif s="Florida" Then ... function StateFromFile(sFileFullName as String) as String ... dim vState as Variant ...
    (microsoft.public.vb.general.discussion)
  • what type of code is this?
    ... but i need to read a csv file that contains information about different concerts and events... ... Dim Data As String ... I need to search within the group of csv files and extract data into an Excel ...
    (microsoft.public.excel.programming)
  • Re: Combine columns from seperate sheets into new sheet- macro imp
    ... sheet and combine them with up to ten columns from another sheet. ... Dim Sheet1 As String ... Dim Column1 As String ... ElseIf A Is Nothing Then ...
    (microsoft.public.excel.programming)
  • Re: How do I pull the info from this PostScript?
    ... Do you just want to extract the title from a file, ... When anchorsearch returns true, the 'post' string ... SourceArrayDecode filter from the array, and cvx exec the filter. ...
    (comp.lang.postscript)
  • Re: Newbie: Array of pointers to strings questions.
    ... > What I'm trying to do is extract information from one file and insert ... The first file has a string of ... > char *ptr; ... line1 is just a constant pointer to a character. ...
    (comp.lang.c)