Connector Mask Field Documentation
Introduction
The "Mask" field in our connector allows you to define rules for filtering files based on their names using regular expressions. This enables you to specify which files the connector should treat or exclude based on your requirements.
Usage
Basic Usage
- To include files based on a specific pattern, you can use inclusive rules.
- To exclude files based on a specific pattern, you can use exclusive rules.
Regular Expressions
Regular expressions provide a flexible and powerful way to define patterns for matching strings. Here's a brief overview of common regular expression syntax:
- . (dot): Matches any single character.
- *: Matches zero or more occurrences of the preceding character.
- +: Matches one or more occurrences of the preceding character.
- ?: Matches zero or one occurrence of the preceding character.
- [ ]: Matches any single character within the brackets.
- ^: Matches the start of the string.
- $: Matches the end of the string.
- |: Represents OR operator.
- \: Escapes special characters.
Examples
Inclusive Rule
To include files with a specific extension (e.g., .pdf), you can use the following regular expression:
Explanation:
- .*: Matches any characters (zero or more) before the file extension.
- \.pdf: Matches the file extension .pdf.
- $: Matches the end of the string.
This rule includes all files ending with .pdf.
Exclusive Rule
To exclude files with a specific extension (e.g., excluding .pdf files), you can use a negative lookahead in your regular expression:
Explanation:
- ^: Matches the start of the string.
- (?!.*\.pdf$): Negative lookahead assertion ensures that the string does not end with .pdf.
- .*: Matches any characters (zero or more).
- $: Matches the end of the string.
This rule excludes all files ending with .pdf.
Conclusion
With the "Mask" field and regular expressions, you have the flexibility to precisely filter files based on your inclusion or exclusion criteria. By understanding and utilizing regular expression patterns effectively, you can tailor the connector's behavior to suit your specific needs.
For additional guidance on regular expressions, you can refer to the following online resources:
https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html