<html>
    <head>
      <base href="https://bugs.documentfoundation.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><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">126764</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>REGEX() function with an integer as 'Occurence' returns the complete 'Text' if the respective match doesn't exist. It should return #N/A.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>LibreOffice
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>6.3.0.2 rc
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>UNCONFIRMED
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Calc
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>libreoffice-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jag@psilosoph.de
          </td>
        </tr></table>
      <p>
        <div>
        <pre>To justify my choice of "major" for severity see last paragraph!

Example

Current behaviour:
=REGEX("12-34-56";"[^-]*-";"";3) returns "12-34-56".

Expected behaviour and reasons:
#N/A should be returned.
Since the ordered replacement couldn't be performed due to the lack of a third
match, the actual behaviour is gravely misleading. 

Additional explanations:
Some real applications will need much more complicated formulae to get a
workaround under the current behaviour.
In an actual use-case I need to rely on something like
=LEFT(REGEX($A9;$E$2;"";1);IF(CURRENT()=$A9;0;1)) instead of the clear and
simple
=IFNA(LEFT(REGEX($A9;$E$2;"";1);1);"")

In more complicated cases it may get difficult if not impossible to catch the
error without helper cells and without relying on functions (SEARCH()
e.g.)capable of applying RegEx ONLY IF the respective global setting is
enabled.

[I do not know how google sheets do whatever concerning REGEX(). Again a case
where conflicts concerning quality vs compatibility may occur. I would
appreciate quality higher generally.]

Since the REGEX() function was only implemented recently (V6.1) it may still be
feasible to change that without endangering the functionality of currently
working sheets. therefore a fix should be created REALLY FAST.</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>