summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2018-11-29 21:04:48 +0100
committerEike Rathke <erack@redhat.com>2018-11-29 21:25:42 +0100
commitee142eec43e73bac7377380c3c72c31600a20355 (patch)
tree3ab16bc2320a88336ddd41dc00d7c11bb3ad0de7
parent49bd9d10394529a2992295735f020aecd81c14ae (diff)
Occurrence number as REGEX() 4th argument, tdf#113977 tdf#121084
Change-Id: I42be8bbc4e7c11e09cb66bf12f164c4fc565b54b Reviewed-on: https://gerrit.libreoffice.org/64276 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins (cherry picked from commit 5f6e0b4ea97c5011a80613fc21a703d2178a8c6e) Reviewed-on: https://gerrit.libreoffice.org/64281
-rw-r--r--source/text/scalc/01/func_regex.xhp9
1 files changed, 6 insertions, 3 deletions
diff --git a/source/text/scalc/01/func_regex.xhp b/source/text/scalc/01/func_regex.xhp
index f83cfac180..bd08223d5f 100644
--- a/source/text/scalc/01/func_regex.xhp
+++ b/source/text/scalc/01/func_regex.xhp
@@ -27,15 +27,18 @@
<paragraph id="par_id541542230672101" role="paragraph" xml-lang="en-US"><variable id="func_regex_desc"><ahelp hid=".">Matches and extracts or optionally replaces text using regular expressions.</ahelp></variable></paragraph>
</section>
<embed href="text/scalc/01/ful_func.xhp#func_head_syntax"/>
- <paragraph role="code" id="par_id701542231253817" xml-lang="en-US">REGEX( Text ; Expression [ ; [ Replacement ] [ ; Flags ] ] )</paragraph>
+ <paragraph role="code" id="par_id701542231253817" xml-lang="en-US">REGEX( Text ; Expression [ ; [ Replacement ] [ ; Flags|Occurrence ] ] )</paragraph>
<paragraph role="paragraph" id="par_id621542232197446" xml-lang="en-US"><emph>Text</emph>: A text or reference to a cell where the regular expression is to be applied.</paragraph>
- <paragraph role="paragraph" id="par_id211542232209275" xml-lang="en-US"><emph>Expression</emph>: A text representing the regular expression, using <link href="https://userguide.icu-project.org/strings/regexp" name="ICU REGEXP">ICU regular expressions</link>. If there is no match, #N/A is returned.</paragraph>
+ <paragraph role="paragraph" id="par_id211542232209275" xml-lang="en-US"><emph>Expression</emph>: A text representing the regular expression, using <link href="https://userguide.icu-project.org/strings/regexp" name="ICU REGEXP">ICU regular expressions</link>. If there is no match and <emph>Replacement</emph> is not given, #N/A is returned.</paragraph>
<paragraph role="paragraph" id="par_id581542232755604" xml-lang="en-US"><emph>Replacement</emph>: Optional. The replacement text and references to capture groups. If there is no match, <emph>Text</emph> is returned unmodified.</paragraph>
<paragraph role="paragraph" id="par_id421542232246840" xml-lang="en-US"><emph>Flags</emph>: Optional. "g" replaces all matches of <emph>Expression</emph> in <emph>Text</emph>, not extracted. If there is no match, <emph>Text</emph> is returned unmodified.</paragraph>
+ <paragraph role="paragraph" id="par_id421542232246841" xml-lang="en-US"><emph>Occurrence</emph>: Optional. Number to indicate which match of <emph>Expression</emph> in <emph>Text</emph> is to be extracted or replaced. If there is no match and <emph>Replacement</emph> is not given, #N/A is returned. If there is no match and <emph>Replacement</emph> is given, <emph>Text</emph> is returned unmodified. If <emph>Occurrence</emph> is 0, <emph>Text</emph> is returned unmodified.</paragraph>
<embed href="text/scalc/01/ful_func.xhp#func_head_example"/>
<paragraph role="paragraph" id="par_id371542291684176" xml-lang="en-US"><item type="input">=REGEX("123456ABCDEF";"[:digit:]";"Z")</item> returns "Z23456ABCDEF", where the first match of a digit is replaced by "Z".</paragraph>
<paragraph role="paragraph" id="par_id891542291697194" xml-lang="en-US"><item type="input">=REGEX("123456ABCDEF";"[:digit:]";"Z";"g")</item> returns "ZZZZZZABCDEF", where all digits were replaced by "Z".</paragraph>
- <paragraph role="paragraph" id="par_id21542291705695" xml-lang="en-US"><item type="input">=REGEX("123456ABCDEF";"[1|2|6]";"";"g")</item> returns "345ABCDEF", where any occurrence of "1", "2" or "6" is replaced by the empty string, thus deleted. </paragraph>
+ <paragraph role="paragraph" id="par_id21542291705695" xml-lang="en-US"><item type="input">=REGEX("123456ABCDEF";"[126]";"";"g")</item> returns "345ABCDEF", where any occurrence of "1", "2" or "6" is replaced by the empty string, thus deleted. </paragraph>
+ <paragraph role="paragraph" id="par_id371542291684177" xml-lang="en-US"><item type="input">=REGEX("axbxcxd";".x";;2)</item> returns "bx", the second match of ".x".</paragraph>
+ <paragraph role="paragraph" id="par_id371542291684178" xml-lang="en-US"><item type="input">=REGEX("axbxcxd";"(.)x";"$1y";2)</item> returns "axbycxd", the second match of "(.)x" (i.e. "bx") replaced with the captured group of one character (i.e. "b") followed by "y".</paragraph>
<section id="relatedtopics">
<paragraph role="paragraph" id="par_id711542233602553" xml-lang="en-US"><link href="text/shared/01/02100001.xhp" name="regex lists">List of regular expressions</link></paragraph>
<paragraph role="paragraph" id="par_id431542233650614" xml-lang="en-US"><link href="https://userguide.icu-project.org/strings/regexp" name="ICU REGEXP">ICU regular expressions</link></paragraph>