IBM Support

Regular expressions in FilenameFunctionSelector in WebSphere Adapter for Flat files

Question & Answer


Question

What are regular expressions and the rules that govern their usage?

Answer

A regular expression is a string that is used to describe or match a set of strings, according to certain syntax rules. The FilenameFunctionSelector provides object name resolution based on regular expressions that map to file names. It can be used with any adapter that uses the “filename” inbound interaction specification property. The regular expression used follows the rules for the standard java.util.regex.* package with UNICODE_CASE flag, making it possible to create complex expressions.

The function selector can be configured with multiple “rules,” each of which contains an object name and a regular expression to match against the file name. The following table presents some examples of matching rules, where a rule consists of the “ObjectName” and the “Rule” fields.

FileNameObjectNameRule
Customer0001.txtCustomerCUST.*TXT
2231ORZ93.z21Order[0-9]*OR[A-Z][0-9]{2}.*
2231ORZ93.z21Order.*OR.*

In the table, the rules in the second and third rows resolve to the same name, but the second is less “greedy,” because it requires a specific sequence of numbers and letters for it to match, whereas the third rule resolves anything with the characters “OR” in the file name. The character combination “.*” means that any character can occur any number of times.

To generate the native function name, the function selector will prepend "emit" to the object name given. The object name should be the payload object name, not the wrapper or business graph name. For pass-through scenarios, use "FlatFile" or "FTPFile" as the object name for the FlatFile and FTP adapters, respectively.

If more than one rule matches, the function selector returns the object name based on the first matching rule. If no rule matches, an error occurs. If no rules at all are present in the configuration, the function selector will use the function names "emitFlatFile" or "emitFTPFile", as though the function selector were configured to use a pass through object for all filenames.

See the following link to the Java™ Pattern documentation for an explanation of the rules that govern the usage of regular expressions: https://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html

[{"Product":{"code":"SSMKUK","label":"WebSphere Adapters Family"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Adapter for FlatFiles","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"6.1","Edition":"","Line of Business":{"code":"","label":""}}]

Document Information

Modified date:
15 June 2018

UID

swg21290287