[Libreoffice-bugs] [Bug 126764] REGEX() function with an integer as 'Occurence' returns the complete 'Text' if the respective match doesn't exist. It should return #N/A.

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Sun Aug 11 12:58:44 UTC 2019


https://bugs.documentfoundation.org/show_bug.cgi?id=126764

Wolfgang Jäger <jag at psilosoph.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jag at psilosoph.de

--- Comment #2 from Wolfgang Jäger <jag at psilosoph.de> ---
(In reply to Eike Rathke from comment #1)
> 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, ...

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).

> 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))

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.

> 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().

You are right.

> 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.

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.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20190811/b6201217/attachment.html>


More information about the Libreoffice-bugs mailing list