Match characters: match_characters
Syntax
match_characters ( op , pattern )
Input parameters
op |
the dataset to be checked |
pattern |
the regular expression to check the Data Set or the Component against |
Examples of valid syntaxes
match_characters(ds1, "[abc]+\d\d")
ds1 [ calc m1 := match_characters(ds1, "[abc]+\d\d") ]
Semantics for scalar operations
match_characters returns TRUE if op matches the regular expression regexp, FALSE otherwise.
The string regexp is an Extended Regular Expression as described in the POSIX standard. Different implementations of VTL may implement different versions of the POSIX standard therefore it is possible that match_characters may behave in slightly different ways.
Input parameters type
op
dataset {measure<string> _}
| component<string>
| string
pattern
component<string>
| string
Result type
result
dataset { measure<boolean> bool_var }
| component<boolean>
| boolean
Additional Constraints
If op is a Data Set then it has exactly one measure.
pattern is a POSIX regular expression.
Behaviour
The operator has the typical behaviour of the “Operators changing the data type” (see the section “Typical behaviours of the ML Operators”).
Examples
Given the operand dataset DS_1:
Input DS_1 (see structure)
Id_1 |
Id_2 |
Id_3 |
Id_4 |
Me_1 |
---|---|---|---|---|
G |
Total |
Percentage |
Total |
AX123 |
R |
Total |
Percentage |
Total |
AX2J5 |
Example 1
DS_r:=match_characters(DS_1, "[:alpha:]{2}[:digit:]{3}");
results in (see structure):
Id_1 |
Id_2 |
Id_3 |
Id_4 |
bool_var |
---|---|---|---|---|
G |
Total |
Percentage |
Total |
True |
R |
Total |
Percentage |
Total |
False |