ph_regexsnap2 PowerHome formula function
Description
Performs a regular expression search against
a string of data and snaps specific
pieces of data out.
Syntax
ph_regexsnap2 ( pattern, data, start,
occur, flags, localsnapcnt, localsnapvars )
Argument |
Description |
pattern |
String. A regular expression search pattern.
The pattern should contains snap patterns. A snap pattern is a portion of
a regular expression contained within open and close parenthesis "(" and
")". |
data |
String. The string in which to perform the
search. |
start |
Long. The position within the data in which to
start the search. Use 1 to start at the beginning. |
occur |
Integer. The occurence of the match you'd like
returned. If a file contains multiple matches and this value is 3,
then the 3rd matching occurence will be returned. |
flags |
Integer . Flags that control how the search is
performed. Set this value to 1 in order to match case. Use 0 for case
insensitive searches. |
localsnapcnt
|
Integer . The index of a local variable
in which to have the count of snapped items returned. Use 0 to not have the count
returned. |
localsnapvars |
Ingeger
. The starting index of a local
variable in which to have the individual snaps returned. If there are 3
snaps to return and this parameter is set to 5, then the snaps will be
returned in [LOCAL5], [LOCAL6], and [LOCAL7]. Use 0 to not have the snaps returned in
local variables.
|
Return value
String. Returns the snapped
expressions.
Usage
This function is very similar to the
ph_regexsnap1 function except that it uses the regular expression engine
contained within the Microsoft VBScript library. The ph_regexsnap1 function
uses the open source Scintilla editor to perform regular expression searches
which is more limited in options and capabilities.
The full documentation for this regular expression library
is way too much information for this help file. Please reference this site for a
very good reference and tutorial for utilizing the Microsoft VBScript regular
expression library:
http://www.regular-expressions.info/vb.html
Examples
The following examples demonstrate typical
syntax/usage for this function.
ph_regexsnap2("def([\S\s]*)mn","abcdefghijklmnopqrstuvwxyz",1,1,0,0,0)
The above example will return "ghijkl".