- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 02:28 AM
Hi all,
Need a help on file path validation for below patterns. Could anyone please help on this
x:\File
\File\File\ or
\File\File or
\File\\File etc
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 07:25 AM
Hi @William08 ,
I have validated the below code in background script can you please check once
var patterns = [
/^E:[\\\/].+[\\\/]?$/,
/^[a-zA-Z0-9_]+([\\\/][a-zA-Z0-9_]+)+[\\\/]?$/,
];
var filePaths = 'E:\\Test/data1/data2/data2/data2/';
gs.print(filePaths);
var pattern = patterns[0]; // Select the first pattern
if (pattern.test(filePaths)) {
gs.print("matched");
} else {
gs.print("mismatched");
}
Output :
*** Script: E:\Test/data1/data2/data2/data2/
*** Script: matched
Shravan
Please mark this as helpful and correct answer, if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 07:25 AM
Hi @William08 ,
I have validated the below code in background script can you please check once
var patterns = [
/^E:[\\\/].+[\\\/]?$/,
/^[a-zA-Z0-9_]+([\\\/][a-zA-Z0-9_]+)+[\\\/]?$/,
];
var filePaths = 'E:\\Test/data1/data2/data2/data2/';
gs.print(filePaths);
var pattern = patterns[0]; // Select the first pattern
if (pattern.test(filePaths)) {
gs.print("matched");
} else {
gs.print("mismatched");
}
Output :
*** Script: E:\Test/data1/data2/data2/data2/
*** Script: matched
Shravan
Please mark this as helpful and correct answer, if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 12:52 AM