This section describes how to use wildcards and regular expressions in CIC. Wildcards and regular expressions are most often used in the paths of GET and PUT commands. Generally, using wildcards and regular expressions is restricted to the filename token of a path. Some cases, however, allow for placement within the directory tokens, as well. Refer to your specific command reference for locations where you can use wildcards and regular expressions. As an introduction, the table below provides some examples.
Command | Result |
---|---|
GET ab*.edi |
Gets all files that match the pattern ab*.edi |
GET ab?.edi |
Gets all files that match the pattern ab?edi |
GET ${regex:ab.*\.edi} |
Gets all files that match the regular expression ab.*\.edi |
Wildcards
Wildcards are represented by *
or ?
, where *
matches multiple characters and ?
matches only a single character. For example, assume a directory has the following files.
ab.edi
ab1.edi
ab2.edi
ab11.edi
ab12.edi
The following commands produce the following results.
Command | Result |
---|---|
GET ab*.edi |
Gets all five files |
GET ab?.edi |
Gets only ab1.edi and ab2.edi |
Note that, when using wildcards, it is possible to use multiple wildcards within the same token. For example, "GET ab*.*" and "GET ab?.*" are both acceptable.
Regular Expressions
Note: Regular Expressions are supported in commands for only AS2, FTP, OFTP, SFTP, S3, Partner Mailbox, GCS, Azure Blob, and RNIF endpoints.
When the basic wildcards do not provide the needed search criteria, regular expressions may be used instead. Regular expressions (abbreviated regex) are composed of a special syntax that enables a wider range of search patterns. All regular expression usage must follow these basic rules.
- The regex pattern must be enclosed in a template of "${regex:regex pattern}" (for example,
${regex:test[ABC]\.edi}
or${regex:test\d\.edi}
). - Only one regex pattern is allowed per token, for example, a filename or a directory token. Furthermore, the pattern must consume the entire token. Below is a table containing some valid and invalid regular expression examples.
Command | Valid/Invalid |
---|---|
GET download/${regex:ab.*\.edi} |
valid |
GET download/ab.*\.edi |
invalid -- regex is not encapsulated within the "${regex:regex pattern}" template |
GET download/ab${regex:.*\.edi} |
invalid -- does not consume the entire filename token |
GET download/${regex:ab.*}.${regex:edi} |
invalid -- contains two regex patterns within one token (i.e., the filename token) |
Regular Expression Constructs
This section provides descriptions of some commonly used constructs within regular expressions. For a more complete list of regular expression constructs and a more detailed discussion, visit http://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html#sum.
Construct | Description |
---|---|
[abc] |
a , b or c
|
[^abc] |
Any character except a , b or c
|
Construct | Description |
---|---|
. |
Any character |
\d |
A digit: (0-9) |
\D |
A non-digit: (^0-9) |
Construct | Description |
---|---|
\p{Lower} |
lowercase alphabetic character |
\p{Upper} |
An uppercase alphabetic character |
\p{ASCII} |
Any ASCII character: (\x00-\x7F) |
\p{Digit} |
A digit: (0-9) |
\p{Alnum} |
An alphanumeric character |
Construct | Description |
---|---|
X? |
X, zero or one time |
X* |
X, , zero or more times |
X+ |
X, , one or more times |
X{n} |
X, , exactly n times |
X{n,} |
X, , at least n times |
X{n,m} |
X, , at least n but not more than m times |
Construct | Description |
---|---|
^ |
Indicates the subsequent characters must appear at the beginning of the string |
$ |
Indicates the preceding characters must appear at the end of the string |
Construct | Description |
---|---|
\ |
Escapes (quotes) the following character. Necessary if you want to match to a period ('.'), bracket ('[]'), brace ('{}') or other special character. |
\Q |
Starts an escaped (quoted) literal string. Literal string should be closed with \E. |
\E |
Ends an escaped (quoted) literal string that was started by \Q. |
Construct | Description |
---|---|
(?i) |
Turn on flag to ignore case. |
(X) |
Match string X . |
(?i:X) |
Match string X , ignoring case. |
(?!X) |
Do not match string X . |
Regular Expression Examples
The table below contains some examples that might be used for file names.
Regex | Matches |
---|---|
${regex:.*} |
Matches any file |
${regex:test.*\.edi} |
Matches test.edi through test (any character(s)) . edi (lower case only) |
${regex:(?i)test.*\.edi} |
Matches test.edi through test (any character(s)) .edi (lower or upper case) |
${regex:(?i)test[abc]{3}\d\.edi} |
Matches testaaa0.edi through testccc9.edi (lower or upper case) |
${regex:test\p{Digit}{1,}\.edi} |
Matches test0.edi through test9.edi, test00 through test99.edi, etc. (lower case only) |
${regex:(?!TestFile)(.*)} |
Matches every file except a file called "TestFile" (case sensitive). |
${regex:(?i)(?!TestFile)(.*)} |
Matches every file except a file called "TestFile" (case insensitive). |
${regex:(?!.*\.edi$)(.*)} |
Matches every file except a file that ends in ".edi" (case sensitive). |
${regex:(?i:(?!.*\.edi$)}(.*)} |
Matches every file except a file that ends in ".edi" (case insensitive). |
${regex:(?!(\.)|(\.\.))(.*)} |
Matches every file except those named "." or "..". |
${regex:(?i)(?!(.*\.tmp$))(.*)} |
Matches every file except those that end in ".tmp" (case insensitive). |
${regex:(?i)(?!(^prefix.*\.tmp$))(.*)} |
Matches every file except those that start with "Prefix" and end in ".tmp" (case insensitive). |
${regex:(?!(TestFile)|(Test\.File))(.*)} |
Matches every file except those named "TestFile" or "Test.File" (case insensitive). |
${regex:(.*)(Primary)(.*)} |
Matches any file that contains the string "Primary" somewhere in it (case sensitive). |
${regex:(.*)(?i:Primary)(.*)} |
Matches any file that contains the string "Primary" somewhere in it (case insensitive). |
${regex:test\.edi} |
Matches only "test.edi". |
${regex:(?i)test\.edi} |
Matches "test.edi" (case insensitive). |
${regex:\+.*} |
Matches every file that starts with "+". |
${regex:\+\+.*} |
Matches every file that starts with "++". |
${regex:\Q+\E.*} |
Matches every file that starts with "+". |
${regex:\Q++\E.*} |
Matches every file that starts with "++". |
${regex:.*\Q+\E.*} |
Matches every file that contains "+" anywhere within the name. |
Note: If you need to download a specific file, but the absence of that file generates an unwanted error, enclose the filename in a regular expression to avoid the error. For example, ${regex:test\.edi}
will match only a file called test.edi.
Comments
0 comments
Please sign in to leave a comment.