# Regex Analysis

Analyzes a string given a regular expression

Category: General

Parameter:

• Regular Expression
• Description: A regular expression containing groups (see http://www.javamex.com/tutorials/regular_expressions/capturing_groups.shtml).
• Occurrence: 1..1
• Output Format
• Description: The output format to apply, containing curly brackets delimited group definitions. Ex. {1} represents the result of group 1 from the regex analysis.
• Occurrence: 1..1
Source:
• Description: The source property to analyze
• Occurrence: 1..1
Target:
• Description: The property that will have the converted string assigned
• Occurrence: 1..1

Function ID: eu.esdihumboldt.cst.functions.string.regexanalysisfunction

### General explanation

This function populates a target property with the groups captured from the regular expression analysis on the source property. The regular expression analysis is carried out basing on the regex-pattern and applying an output format to the extracted regular expression groups.

Information about regular expression groups can be found here.

### Example

Let us assume that the source property represents a date of the format:

20081209

and that the target property needs a date in the format :

YYYY-MM-DD HH:MM:SS

We can use a regular expression like:

([0-9]{4})([0-9]{2})([0-9]{2})

and an output format:

{1}-{2}-{3} 00:00:00

to achieve our goal.

In fact the result of the above example will result in:

2008-12-09 00:00:00

#### Explained

The regular expression used defines 3 groups, which are separated by the round brackets:

 Regex Group Explained Caught part of 20081209 ([0-9]{4}) catches 4 numbers between 0 and 9 2008 ([0-9]{2}) catches 2 numbers between 0 and 9 12 ([0-9]{2}) catches 2 numbers between 0 and 9 09

The output can then be formatted concatenating groups with any string.

The format {1}-{2}-{3} 00:00:00 simply defines that the first three groups will be concatenated by a dash and that a default time will be added at the end of the resulting string.