5
5
$rsearch
6
6
========
7
7
8
- | Usage: **$rsearch(text,pattern)**
8
+ | Usage: **$rsearch(text,pattern[,group] )**
9
9
| Category: text
10
10
11
11
**Description: **
@@ -21,6 +21,13 @@ If more than one marked subexpression is defined and not all are matched, an emp
21
21
be returned. If no subexpression is specified, then the pattern captured by the whole search
22
22
expression will be returned.
23
23
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
+
24
31
.. note ::
25
32
26
33
When entering regular expressions into Picard scripts you have to escape a backslash "\\ ",
@@ -29,6 +36,10 @@ expression will be returned.
29
36
a backslash before the character to be escaped. For example, the regular expression
30
37
``^\s*([0-9,\.]*)$ `` would have to be entered as ``^\\s*\([0-9\,\\.]*\)\$ ``.
31
38
39
+ .. note ::
40
+
41
+ The ``group `` argument was added in Picard v2.14.
42
+
32
43
**Example: **
33
44
34
45
The following statements will return the values indicated:
@@ -44,3 +55,5 @@ The following statements will return the values indicated:
44
55
$rsearch(test,\(e\).*\(s\)) ==> "e"
45
56
$rsearch(test,\(e\).*x) ==> ""
46
57
$rsearch(test,\(e\).*\(x\)) ==> ""
58
+ $rsearch(disc: 3,\(\\w+\): \(\\d+\),1) ==> "disc"
59
+ $rsearch(disc: 3,\(\\w+\): \(\\d+\),2) ==> "3"
0 commit comments