I need two regularexpressions that will work in .Net
The first one is for valid unc paths to file shares..
server,share,folder names can be any vailid windows name
so these are valid
\\server\share
\\server\share name
\\server\share$
\\server\share$\folder
etc
these are not valid
\\server\share\ <- cant end in slash
\\server\share\file.ext
The second one is similar but for folders
valid
c:\
c:\foldername
c:\folder name
c:\foldername\foldername
no valid
c:
c:\foldername\
c:\foldername\foldername\
c:\foldername\file.ext
so again can not end in a slash unless its a root path. All valid
windows folder names allowed.
Any help appreciated as regular expressions.. I just cant get my head
round.
Thanks
Amit
Thanks for the help.
The reason I am using the reg ex is to validate input into a fileserver
database. Two of the input fields are share name, and physical path.
Thats why I need seperate expressions for each field.
How can I split the expression you have created into two?
With regards to where to end the expression.. can you not read it up to
the end of line? The data is coming from a user input textbox so
everything entered needs to be valid.
"\\server\share name this is really a cool software repository!" is a
valid share name
also.. with regards to the slash.. after C:\ can we make it so we can
have an optional slash at the end? so c: and c:\ are vaild? Same with
the foldernames.. if c:\foldername\ is valid, I can deal with the
trailing slash in code.
So basicaly.. if you could modify the regex to allow \ at the end of a
folder name, and also split the UNC and the Physical path names that
would be great.
Also.. where is a good place to learn regular expressions.. ?
Amit