Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Gateways

Using Regular Expressions for Filters and Mappings

  • Last UpdatedOct 24, 2024
  • 2 minute read

AVEVA™ Gateway for Unified Engineering (gateway) provides three PML functions related to Regular Expressions that can be used when applying filters and configuring mappings.

This section describes the three PML functions.

define function !!regexmatches(!text is STRING, !regex is STRING) is BOOLEAN

--  Description:

--  Function to test if given text string matches particular regular expression.

--

------------------------------------------------------------------------

--

-- Function Type:  Function/Procedure

-- Arguments:

--  [#] [R/RW] [Data Type] [Description]

--  1  R  STRING  Text to test with given regular expression

--  2  R  STRING  The regular expression to which this string is to be matched

-- Return:

--  [Data Type] [Description]

--  TRUE  If text string matches the given regular expression.

--  FALSE  Otherwise.

------------------------------------------------------------------------

Example:

!!regexmatches(:DisplayName, 'P-[0-9]*')

Depending of attribute :DisplayName value, function will return as follows:

‘P+22’  -> FALSE

‘P-067’ -> TRUE

‘P-23’ -> TRUE

‘S-067’ -> FALSE

‘D-23’ -> FALSE

define function !!regexreplaceall(!text is STRING, !regex is STRING, !replacement is STRING) is STRING

--  Description:

--  Function that returns a string after it replaces each substring of that matches the given regular expression with the given replacement.

--

------------------------------------------------------------------------

--

-- Function Type:  Function/Procedure

-- Arguments:

--  [#] [R/RW] [Data Type] [Description]

--  1  R  STRING  Input text to replace matches using regular expressions

--  2  R  STRING  The regular expression to which this string is to be matched

--  3  R  STRING  Replacement string which will be used to replace all matches

-- Return:

--  [Data Type] [Description]

--  STRING  Text with all matched regular expression patterns replaced

------------------------------------------------------------------------

Example:

!!regexreplaceall(:DisplayName, '-[0-9]*', '-XXX')

Depending of attribute :DisplayName value, function will return as follows:

‘P+22’  -> ‘P+22’

‘P-067’ -> ‘P-XXX’

‘P-23’ -> ‘P-XXX’

‘S-067’ -> ‘S-XXX’

‘D-23’ -> ‘D-XXX’

define function !!regexsplit(!text is STRING, !regex is STRING) is ARRAY

--  Description:

--  Function that returns an array of strings which were separated using delimiter substring or regular expression.

--

------------------------------------------------------------------------

--

-- Function Type:  Function/Procedure

-- Arguments:

--  [#] [R/RW] [Data Type] [Description]

--  1  R  STRING  Input text to split using delimiter substring or regular expression

--  2  R  STRING  Delimiter substring or regular expression to use for splitting input text

-- Return:

--  [Data Type] [Description]

--  ARRAY  Array of string

------------------------------------------------------------------------

Example:

!!regexsplit(:DisplayName, '-')

Depending of attribute :DisplayName value, function will return as follows:

‘P+22’  -> ‘P+22’

‘P-067’ -> ‘P’, ‘067’

‘P-23’ -> ‘P’, ‘23’

‘S-067’ -> ‘S’, ‘067’

‘D-23’ -> ‘D’, ‘23’

Related Links
TitleResults for “How to create a CRG?”Also Available in