Governing Variant Creation with Regex Rules
Description: This functional guide discusses the use of Regex patterns to determine which variants to produce when images are uploaded into EnterWorks.
EnterWorks Product Applicability: EnterWorks, All Versions (10.0+, 9.0, 8.2, 7.4)
Regex Patterns
"Regex" stands for "regular expression" (or sometimes "rational expression"). It is a syntax used to describe alphanumeric patterns in strings. It is often used in search engines to describe the pattern of characters being searched for. More information about regex patterns is readily available on the internet. Examples of the use of regex pattern-matching in EnterWorks are found at the end of this document.
How Image Variants are Created
The DAMVariants repository’s records define the image variants that can be created by EnterWorks and indicate which variants will be created when a specific image file is uploaded.
Each record in DAMVariants describes one image variant that can be created. The record’s attributes include values such as the dimensions of the variant, the image quality, whether to include a watermark, the text of the watermark, and compression quality.
One of DAMVariants repository’s attributes is titled Regex Rule. The Regex Rule attribute is optional; if present, it contains a regex pattern expression.
The Regex Rule attribute controls whether or not the variant will be created for a particular image uploaded into EnterWorks.
How Regex Patterns are Used by EnterWorks
When an image is uploaded into EnterWorks, DAM checks the Regex Rule attribute value for each record in the DAMVariants repository to see if the variant described by that record is to be generated.
If the Regex Rule attribute is empty, DAM generates the variant described by that record.
If the Regex Rule attribute is not empty, DAM evaluates the Regex Rule’s value to see if the image’s filename matches the given regex pattern. If it does, the variant is generated. If the filename does not match the regex pattern, the variant is not generated.
Examples
If a certain variant’s record in DAMVariants has a Regex Rule value of
_Install
and digital assets with the following
filenames are uploaded:
123_Install.jpg
A_test_Install.tif
Product12.png
the first two file names will match the regex pattern and the last one will not, therefore, DAM will generate the variants for:
123_Install.jpg
A_test_Install.tif
For a Regex Rule value of:
[0-9]*_merch_frt[0-9]*_[a-zA-Z]*
images with the filenames:
123_merch_frt_938984_ajklj.tif
9_merch_frt_0_z.eps
_merch_frt__.eps
match the pattern, therefore variants would be created for them. (An asterisk means zero or more of the preceding element, therefore, the last filename matches the pattern.)
Images with the following filenames would not match the pattern:
984_merch_bck_899_dog.tif
abc_merch_frt_90_aa.eps
182_merch_frt_983_983.jpg