Hi,
I'm using C# 2.0 on Visual Studio 2005.
I need a regular expression to parse a string with multiple filenames, filepaths, directories and whatnot and separate them. Filepaths often have spaces, so quotes are used to delimit them. There are some invalid characters in a file path, but for this particular application, there's no need to look for them.
For example, when input :
"c:\mes documents\tmp\cator\*.castor" "c:\www\" "file.castor"
There are 3 matches :
c:\mes documents\tmp\cator\*.castor
c:\www\
file.castor
input will always be single line.
I use this regular expression : "\"([^\"]*)\"" and it partially works : I'm getting all 3 matches, but with quotes before and after each match.
In addition, I'd like to have the regular expression also capture the filename if there were no quotes, in that case, each path would be space separated. In fact, filepath validation is not even part of the problem : we can always suppose that the entered paths are valid, and if not, that's a problem I'll solve programmatically ("bad user, bad user!").
Could you help me with such a regular expression?