Skip to content

Commit e517bd7

Browse files
authored
Merge pull request #230 from phw/PICARD-3072-rsearch-group
PICARD-3068: Document group parameter for $rsearch (PICARD-3072)
2 parents 934c7f8 + b762c6b commit e517bd7

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

functions/func_rsearch.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
$rsearch
66
========
77

8-
| Usage: **$rsearch(text,pattern)**
8+
| Usage: **$rsearch(text,pattern[,group])**
99
| Category: text
1010
1111
**Description:**
@@ -21,6 +21,13 @@ If more than one marked subexpression is defined and not all are matched, an emp
2121
be returned. If no subexpression is specified, then the pattern captured by the whole search
2222
expression will be returned.
2323

24+
If the optional ``group`` parameter is not provided or is empty, return the first
25+
capture group which matched something (including the empty string) or the
26+
entire match.
27+
28+
If ``group`` is an integer, return the capture group in the position matching this integer.
29+
Otherwise, return the capture group named ``group``, sans surrounding whitespace.
30+
2431
.. note::
2532

2633
When entering regular expressions into Picard scripts you have to escape a backslash "\\",
@@ -29,6 +36,10 @@ expression will be returned.
2936
a backslash before the character to be escaped. For example, the regular expression
3037
``^\s*([0-9,\.]*)$`` would have to be entered as ``^\\s*\([0-9\,\\.]*\)\$``.
3138

39+
.. note::
40+
41+
The ``group`` argument was added in Picard v2.14.
42+
3243
**Example:**
3344

3445
The following statements will return the values indicated:
@@ -44,3 +55,5 @@ The following statements will return the values indicated:
4455
$rsearch(test,\(e\).*\(s\)) ==> "e"
4556
$rsearch(test,\(e\).*x) ==> ""
4657
$rsearch(test,\(e\).*\(x\)) ==> ""
58+
$rsearch(disc: 3,\(\\w+\): \(\\d+\),1) ==> "disc"
59+
$rsearch(disc: 3,\(\\w+\): \(\\d+\),2) ==> "3"

0 commit comments

Comments
 (0)