Hi all,
I am new to regex and need some help.
I have a file path and file name in a
String. This file path and file name are accessed from a Windows machine as well as Mac machine. So, when created via the Mac machine, file path and file name can have special characters like * @ $ ? etc., but that gives trouble to my code running on Windows machine. So, I would like to write a piece of code that checks for the presence of special characters (pretty much everything other than a-z, A-Z, 0-9, _, -) in the file path or file name; and accordingly perform rest of the activities.
The part where I seek your help is writing the regex expression:
Point to note: The filePath is the path of the file plus the file name and extension. Example: \\prod1\customer1\title1\myFile.jpg
And it can be any level deeper, so I have to validate the whole path and the file name.
According to my understanding, below will be the code to perform the above:
As I mentioned, I am new to regex, if there is any mistake in my regex code, please point that out too.
Thanks much!