Using Regular Expressions
Posted by - NA -, Last modified by Aly Essa on 26 May 2016 03:42 PM

Regular Expressions

FileCatalyst utilizes Java regular expressions, allowing you to build complex file filters to select which file you want to include in a transfer.

For additonal documentation to how Java implements regular expressions, the following sources may be used:

http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html
http://www.sitepoint.com/article/java-regex-api-explained/

Example usage:

1) Transfer only files that end with ".dat". Windows wildcard equivalent of "*.dat"

".*\.dat$"
".*" --> any character, 0, 1, or multiple times
"\." --> followed by a period (you must escape dot character, or it will be treated as a wild card)
"dat" --> the exact characters dat all lowercase
"$" --> must be at end of the line

2) Transfer sound files (.mp3 or .wav) with numbers in the title

".*[0-9]+.*\.(mp3|wav)$"
".*" --> any character, 0, 1, or multiple times
"[0-9]+" --> is any numerical digit one or more times
".*" --> any character, 0, 1, or multiple times
"\." --> followed by a period (you must escape dot character, or it will be treated as a wild card)
"(mp3|wav)" --> last characters may match exactly "mp3" OR "wav" -- all lowercase
"$" --> must be at end of the line

3) Transfer everything except temporary files ending in ".tmp"

".*\.[^(tmp)]$"
".*" --> any character, 0, 1, or multiple times
"\." --> followed by a period (you must escape dot character, or it will be treated as a wild card)
"[" --> Start of a block
"^(tmp)" --> exclude files with "tmp" in the name
"]" --> end the block
"$" --> must be at end of the line
Note: Because Javascript will try to interpret some characters, the following actions must be taken into consideration:

You must double up backslash characters (javascript inteprets a single backslash as an escape character)
convert any "+" signs as "%2B", as they will be removed by javascript (into spaces)
convert any "%" into "%25", as the java script may not start up

Adding a regular expression to filter out .mp3 files in the upload applet in File Catalyst Webmail

1. Click the link to Configure Upload Applet in Applet Settings.
2. Add the following to the list of var entries: var regex = ".*\.[^(mp3)]$";
3. Search for this line:
document.writeln('<PARAM NAME = "debug" VALUE = "'+debug+'">');
3.1 Add this after it:
document.writeln('<PARAM NAME = "regex" VALUE = "'+regex+'"> ');
4. Search for this line:
document.writeln("debug='"+debug+"'");
4.1 Add this after it:
document.writeln("regex='"+regex+"'");

Finally you can ingnore case sensitivty in your expressions by adding (?i) at the begining of your filter ie:

regex=((?i)(mov|wmx|mp4|avi|))

This will allow both .MOV and .mov files

Applet Specific

Because Javascript will try to interpret some characters the following actions must be taken into consideration:

  • You must double up backspace characters(Javascript interprets a single backspace as an escape character)
  • Convert and "+" signs to "%2B" , as they will be removed by Javascript (into spaces)
  • Convert any "%" into "%25" , as the Javascript may not start up.