Menu

#27 Add regular expression functionality

open
5
2013-02-14
2003-05-16
Chris Webb
No

It would be great if regular expressions could be used
to search for information within strings such as http
responses. I would propose two new functions
~LOCATEEXPR and ~EXTRACTEXPR functions, although the
existing functions ~LOCATE and ~EXTRACT may be extended
to include this functionality.

The following example extracts the value of the 'expr'
attribute from an element that contains an name
attribute with a value of 'emailCount'. e.g.
<assign expr="2" name="msgCount"/>

The ~LOCATEEXPR would be identical to the ~LOCATE
funtion except the substring would be a regular
expression and return an integer array containing two
elements, the first element containing the offset of
the start of the match and the second element
containing the offset of the character after the match.
Format:
~LOCATEEXPR (expr, string)

Example:
SET offsets = ~LOCATEEXPR
("<assign.*name="emailCount".*/>", teststr)

The ~EXTRACTEXPR function would take a regular
expression that specifies sub-expressions to extract
and return an array of character variables containing
the specified sub-expressions.
Format:
~EXTRACTEXPR (offset, expr, string)

Example:
SET results = ~EXTRACT(offsets[1], "expr=\"(\d*)\"",
TESTSTR)

SET msgCount = results[1]

Discussion


Log in to post a comment.

Monday.com Logo