This section describes the usage of wildcards and regular expressions. Wildcards and regular expression are most often used in the paths of GET, PUT, LCOPY, LDELETE, LREPLACE, and CHECK commands. The CHECK is only available with the Cleo Harmony and Cleo VLTrader applications. Generally, wildcards and regular expressions are restricted to use only within 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 |
---|---|
PUT myOutbox\ab*.edi |
Searches myOutbox for all files that match the pattern ab*.edi |
PUT myOutbox\ab?.edi |
Searches myOutbox for all files that match the pattern ab?edi |
PUT myOutbox\[ab.*\.edi] |
Searches myOutbox for all files that match the regular expression ab.*\.edi |
CHECK *box\[ab.*\.edi] |
Searches first for directories that end in box (for example, inbox or outbox ) and next for files that match the regular expression ab.*\.edi
|
CHECK *box\[a.*]\[ab.*\.edi] |
Searches first for directories that end in box (for example, inbox or outbox ), and next for the subdirectories that match the regular expression a.* , and finally for 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 the outbox has the following files.
ab1.edi
ab2.edi
ab11.edi
ab12.edi
The following commands produce the following results.
Command | Result |
---|---|
PUT ab*.edi |
Sends all four files from the outbox |
PUT ab?.edi |
Sends only ab1.edi and ab2.edi |
Note that, when using wildcards, it is possible to use multiple wildcards within the same token. For example, "PUT ab*.*" and "PUT ab?.*" are both acceptable.
Regular Expressions
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 brackets (for example,
[test[ABC]\.edi]
or[test\d\.edi]
). Note that, as seen in this example, it is possible for a regular expression to contain brackets as part of the pattern definition itself; however, it is still necessary to enclose the complete pattern in its own pair of brackets. - 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 |
---|---|
PUT myOutbox\[ab.*\.edi] |
valid |
PUT myOutbox\ab.*\.edi |
invalid -- does not contain the brackets |
PUT myOutbox\ab[.*\.edi] |
invalid -- does not consume the entire filename token |
PUT myOutbox\[ab.*].[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 name searches.
Regex | Matches |
---|---|
[.*] |
Matches any file |
[test.*\.edi] | Matches test.edi through test (any character(s)) . edi (lower case only) |
[(?i)test.*\.edi] |
Matches test.edi through test (any character(s)) .edi (lower or upper case) |
[(?i)test[abc]{3}\d\.edi] |
Matches testaaa0.edi through testccc9.edi (lower or upper case) |
[test\p{Digit}{1,}\.edi] |
Matches test0.edi through test9.edi, test00 through test99.edi, etc. (lower case only) |
[(?!TestFile)(.*)] |
Matches every file except a file called "TestFile" (case sensitive). |
[(?i)(?!TestFile)(.*)] |
Matches every file except a file called "TestFile" (case insensitive). |
[(?!.*\.edi$)(.*)] |
Matches every file except a file that ends in ".edi" (case sensitive). |
[(?i:(?!.*\.edi$))(.*)] |
Matches every file except a file that ends in ".edi" (case insensitive). |
[(?!(\.)|(\.\.))(.*)] |
Matches every file except those named "." or "..". |
[(?i)(?!(.*\.tmp$))(.*)] |
Matches every file except those that end in ".tmp" (case insensitive). |
[(?i)(?!(^vltrader.*\.tmp$))(.*)] |
Matches every file except those that start with "VLTrader" and end in ".tmp" (case insensitive). |
[(?!(TestFile)|(Test\.File))(.*)] |
Matches every file except those named "TestFile" or "Test.File" (case insensitive). |
[(.*)(Primary)(.*)] |
Matches any file that contains the string "Primary" somewhere in it (case sensitive). |
[(.*)(?i:Primary)(.*)] |
Matches any file that contains the string "Primary" somewhere in it (case insensitive). |
[test.edi] |
Matches only "test.edi". |
[(?i)test.edi] |
Matches "test.edi" (case insensitive). |
[\+.*] |
Matches every file that starts with "+". |
[\+\+.*] |
Matches every file that starts with "++". |
[\Q+\E.*] |
Matches every file that starts with "+". |
[\Q++\E.*] |
Matches every file that starts with "++". |
[.*\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,
[test\.edi]
will match only a file calledtest.edi. - For
LCOPY -REC
commands, the final token cannot be a file. To get around this restriction, enclose the filename in brackets. For example,outbox/test/[test.edi]
.
Comments
0 comments
Please sign in to leave a comment.