cancel
Showing results for 
Search instead for 
Did you mean: 

Using simple wildcards in a Filter Snap?

graham-onpoint
New Contributor II

I have a pretty simple Pipeline that gets a directory listing from Box, filters those files according to their filename, then calls Pipeline Execute to fetch the contents of the matched files using this syntax:

$FileName.match(_FILE_NAME_MATCH)!=null

Here is the filter:

image

I have six files in this folder:

image

When I set FILE_NAME_MATCH to “test” I get the two matching files:

image

I get the same result when I set this variable to “test*”. However, I get zero results when I set it to “test*.csv”:

image

I checked the same regex in JavaScript and no, it’s not a valid search query (i.e. SnapLogic is behaving as expected)

Given that my sysadmins who will be setting up the parameters for these jobs don’t know regex, is there a way for me to use simple Windows File System wildcard searching in the Filter Snap?

They may want to scan for files like this…

output??report(*).xls?

…and not have to know the regex to get it.

2 REPLIES 2

nsingam
Employee
Employee

@graham-onpoint
Given that if you do not want to use the Regex and to achieve this you may need to configure two parameters.
1.The match string without file extension which you are using FILE_NAME_MATCH(in this case test)
2.File extension as FILE_EXT(in this case .csv)
With those two parameters defined you can use the expression in the filter like this.

$filename.match(_FILE_NAME_MATCH) != null && $filename.toLowerCase().endsWith(_FILE_EXT)

Hope this is helpful

graham-onpoint
New Contributor II

Thank you for the suggestion. I think that I’m just going to write the regex for them.