rodchar,
Are you wanting a Regular expression that matches any file name in any
folder?
Or one that specifically matches a file name in a specified root folder?
Do you want to support optional extensions?
Do you want to support only DOS file names (8.3) or long file names?
Do you want to support optional path separators? (both forward & backward
slashes)
Do you want to support UNC names?
The following matches 8.3 names in the root folder:
Const pattern As String = "^[a-zA-z]:\\(\w+)\.(\w+)$"
Static fileNameRegex As New Regex(pattern, RegexOptions.Compiled)
Debug.WriteLine(fileNameRegex.IsMatch("c:\filename.txt"))
Debug.WriteLine(fileNameRegex.IsMatch("c:\filename"))
Debug.WriteLine(fileNameRegex.IsMatch("c:\.txt"))
Debug.WriteLine(fileNameRegex.IsMatch("filename.txt"))
Debug.WriteLine(fileNameRegex.IsMatch("filename"))
The pattern "^[a-zA-z]:\\(\w+)\.(\w+)$" will match an upper or lower case
ASCII letter, followed by a colon, followed by a backward slash, followed by
one or more letters, followed by a period, followed by one or more letters.
The entire pattern needs to be the only thing in the string.
Unfortunately there is no clear RegEx newsgroup. In addition to the
microsoft.public.dotnet.general newsgroup, I would recommend
microsoft.public.dotnet.framework. However! Asking here is probably just as
good in most cases!
A tutorial & reference on using regular expressions:
http://www.regular-expressions.info/
The MSDN's documentation on regular expressions:
http://msdn.microsoft.com/library/d...l/cpconRegularExpressionsLanguageElements.asp
Hope this helps
Jay
Hope this helps
Jay