Regular expression to avoid some files from the folder


I have a requirement to avoid the files which start with AA and XAA from the given folder. I am using listFilesInDirectory service to fetch the files. I can substring the file name and then put a condition to avoid the files. But i want to use regular expression in listFilesInDirectory service, so that i can get the files which doesnot start with AA or XAA.
I have tried with [^AA]|[^XAA] but didnt work out.

Please provide your suggetions…

Thanks in advance.


I don’t have a solution for you but keep in mind that […] indicates a set, not a sequence. Thus, [^XAA] means doesn’t start with X or A or A.

Try setting a branch to say <> /^XAA/ (Use slashes / not brackets [])

Using /^XAA/ means select switch that starts with “XAA”. So by putting the not equals in front of it you should get a selection that does not begin with “XAA”

Sorry I missed this before. The listFilesInDirectory service (from WmSamples) does not support the use of regular expressions. It supports ? and * wildcards only.

Your options:

  • Use the regex matching of BRANCH steps as jday suggests to filter the list in a FLOW service.

  • Locate or write your own FilenameFilter class to support regex to use in your own listFiles service.