- Print
- DarkLight
- PDF
Extract data from a dynamic mask
Purpose of the article
When it comes to extracting data from a character string (e.g. the name of a file), the dynamic mask is particularly useful. However, such extraction requires applying constraints to allow robust and relevant extraction.
Regular expression
The mere use of a dynamic mask does not guarantee the accuracy of the extraction of information. Thus for example in the code STATION-FT-EL-001 it is necessary to indicate to the application that this code
- Must start with the string STATION-
- That it is then followed by 2 alphanumeric characters, followed by a dash
- Then again 2 alphanumeric characters, followed by a dash
- And finally a combination of 3 digits
The regular expression therefore takes on its full meaning, which makes it possible to apply constraints on the code.
Thus the extraction syntax of this code will be noted as follows: STATION-(?<demo_en_type>[a-zA-Z]{2,2})-(?<demo_en_package>[a-zA-Z]{2,2})-(?<demo_en_number>[0-9]{3,3})
Extract data to Cooperlink or perform a check
The advantage of regular expression is to allow the use of a character string (e.g. the file name) to automatically encode the metadata in Cooperlink (this is called extraction) or to perform a check (e.g. check if it is a new document or an existing document with the same code).
To link a group of the regular expression to a Cooperlink metadata, simply use the following notation: (?<metadata_label>[constraint])
- Parentheses identify the group
- Cooperlink associates the read data with the metadata with the name between the signs < >
- The constraint makes it possible to define the process of reading and validating the data.
All methods of regular expression are available without restriction.
When it comes to Value List metadata, Cooperlink performs an additional check, which is to check whether the value read is an available value in the list.
Example of a regular expression used for extracting the file name (encoding metadata and automatic detection of revisions):
Example when uploading documents
In this example, when submitting a document, Cooperlink analyzes the file name to retrieve the essential values, detect whether it is a new document or a revision, and it also detects the revision index when it is specified in the document name.
The user is directly informed when the extraction system has successfully operated or if a non-compliance has been detected (barcode column).