The <AttributeValueIsLike/> operator can use regular expressions to search and replace text. Regular expressions are based on the Perl 5.8 language.
An example of a regular expression used in conjunction with this tag is shown below:
<AttributeValueIsLike Acronym="TXTDSC" Value="[A-Z0-9]{2}[A-Z0-9_]{6}\.TXT" MatchCase="True" /> |
For information about Perl regular expressions, see
http://perldoc.perl.org/perlre.html
These examples of regular expressions could be used to match attribute values:
Purpose | Regular Expression |
|---|---|
Match any string | <AttributeValueIsLike Acronym="ABC" Value=".*" /> |
Match a string in the middle of a value | <AttributeValueIsLike Acronym="ABC" Value=".\bstring_to_match\b." /> For example, |
Match a string at the beginning of a value | <AttributeValueIsLike Acronym="ABC" Value="string_to_match\b.*" /> For example, |
Match a string at the end of a value | <AttributeValueIsLike Acronym="ABC" Value=".*\bstring_to_match" /> For example, |
Match either upper or lower case | <AttributeValueIsLike Acronym="ABC" Value="[Ss]kipper" /> This will match |
Match a sequence of numeric values - either 4 or 8 numbers | <AttributeValueIsLike Acronym="DATEND" Value="[0-9]{4,8}"/> This will match |
Match two upper case characters | <AttributeValueIsLike Acronym="NATION" Value="[A-Z]{2}" MatchCase="True"/> This will match |