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

--- Comment #1 from Eike Rathke <[email protected]> ---
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, if there is no match then
nothing is replaced. Specifically gawk's gensub() that knows the occurrence
parameter as well behaves the same:

  gawk -e '{print gensub(/b/,"",1)}'

Try with different input of "a" and "b".

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

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

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.

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to