regmatches
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | regmatches [2009/06/02 15:52] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | # $EPIC: regmatches.txt, | ||
+ | ======Synopsis: | ||
+ | $[[regmatches]](< | ||
+ | |||
+ | ======Technical: | ||
+ | This function matches a regular expression much like [[regexec]] does, | ||
+ | except it honors subexpressions in the regular expression. It will return | ||
+ | at most <max matches> pairs of numbers describing the start and length of | ||
+ | any matches and submatches found. Each pair is suitable for passing to | ||
+ | [[mid]]. | ||
+ | |||
+ | The first pair of numbers returned is always the entire string matched. | ||
+ | If you wish to match any subexpressions you must specify at least 2 for | ||
+ | <max matches> | ||
+ | |||
+ | ======Returns: | ||
+ | Returns a list of number pairs, with each suitable for passing to $[[mid]]() | ||
+ | to extract the substring. | ||
+ | |||
+ | If the < | ||
+ | the false value is returned. | ||
+ | |||
+ | ======Example: | ||
+ | < | ||
+ | @ orig_string = 'abc def'; | ||
+ | @ pattern = regcomp(abc \(def\))); | ||
+ | @ substrings = regmatches($pattern 2 $orig_string); | ||
+ | fe ($substrings) x y { | ||
+ | if (y != strlen($orig_string)) { | ||
+ | @ rvalue = mid($x $y $orig_string); | ||
+ | echo $rvalue; | ||
+ | }; | ||
+ | }; | ||
+ | | ||
+ | </ | ||
+ | |||
+ | When run, this will return " | ||
+ | |||
+ | ======More Info:====== | ||
+ | See the [[regex]] page for more info. | ||
+ | |||
+ | ======History====== | ||
+ | This function first appeared in EPIC4-1.1.3. | ||
+ | did not support subexpressions. | ||
+ | |||
regmatches.txt · Last modified: 2009/06/02 15:52 by 127.0.0.1