Re: Help With Regular Expression (Another Post)
- From: "Dmitriy Antonov" <antonovdima@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 26 Aug 2006 18:22:00 -0400
"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.
.
- Follow-Ups:
- Re: Help With Regular Expression (Another Post)
- From: OdAwG
- Re: Help With Regular Expression (Another Post)
- References:
- Help With Regular Expression (Another Post)
- From: Odawg
- Help With Regular Expression (Another Post)
- Prev by Date: Re: Show multiple standard exe forms in task bar
- Next by Date: Re: Show multiple standard exe forms in task bar
- Previous by thread: Help With Regular Expression (Another Post)
- Next by thread: Re: Help With Regular Expression (Another Post)
- Index(es):
Relevant Pages
|