<html>
<head>
<base href="https://bugs.documentfoundation.org/">
</head>
<body><span class="vcard"><a class="email" href="mailto:jag@psilosoph.de" title="Wolfgang Jäger <jag@psilosoph.de>"> <span class="fn">Wolfgang Jäger</span></a>
</span> changed
<a class="bz_bug_link
bz_status_UNCONFIRMED "
title="UNCONFIRMED - REGEX() function with an integer as 'Occurence' returns the complete 'Text' if the respective match doesn't exist. It should return #N/A."
href="https://bugs.documentfoundation.org/show_bug.cgi?id=126764">bug 126764</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">CC</td>
<td>
</td>
<td>jag@psilosoph.de
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_UNCONFIRMED "
title="UNCONFIRMED - REGEX() function with an integer as 'Occurence' returns the complete 'Text' if the respective match doesn't exist. It should return #N/A."
href="https://bugs.documentfoundation.org/show_bug.cgi?id=126764#c2">Comment # 2</a>
on <a class="bz_bug_link
bz_status_UNCONFIRMED "
title="UNCONFIRMED - REGEX() function with an integer as 'Occurence' returns the complete 'Text' if the respective match doesn't exist. It should return #N/A."
href="https://bugs.documentfoundation.org/show_bug.cgi?id=126764">bug 126764</a>
from <span class="vcard"><a class="email" href="mailto:jag@psilosoph.de" title="Wolfgang Jäger <jag@psilosoph.de>"> <span class="fn">Wolfgang Jäger</span></a>
</span></b>
<pre>(In reply to Eike Rathke from <a href="show_bug.cgi?id=126764#c1">comment #1</a>)
<span class="quote">> There is no 3rd occurrence of the expression in text, hence nothing is
> replaced. This essentially is similar to =REGEX("a";"b";"") and is standard
> replacement behaviour in tools like sed and awk, ...</span >
Sorry, I lack the needed knowledge, and I am afraid I will not be able to make
it available to me soon(or at all).
<span class="quote">> If you need to check if there actually is a 3rd occurrence to be replaced
> then do an explicit check:
> =IF(ISNA(REGEX("12-34-56";"[^-]*-";;3));NA();REGEX("12-34-56";"[^-]*-";"";3))</span >
Well, I have to apologize that I had not even studied the help on REGEX()
thorougly enough. Having caught up on this, however, I still cannot easily be
satisfied with using presence/absence of an optional parameter this way. Does
not cause inconsistencies, but also doesn't fit into any scheme or concept I
would know of.
<span class="quote">> Unconditionally returning #N/A if there is no match in the replace case IMHO
> is not an option, otherwise the usual logic of replacements with regular
> expressions would be negated and all replacements would have to use IFNA().</span >
You are right.
<span class="quote">> What we maybe could do is add an optional parameter to the function whether
> #N/A shall be returned in replace cases or not. That would have to be hidden
> in the Function Wizard and input hints as we have UI translations freeze for
> 6.3, but in general would be possible even for 6.3. Earlier releases reading
> such additional parameter if present of course would fail then.</span >
No actual need to get into tat trouble, I think.
I would suggest to set this bug RESOLVED NOTABUG, but I hesitate to do it
myself.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>