<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 - Regular expression match function, please?"
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=123000">123000</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Regular expression match function, please?
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>enhancement
          </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>turbobeholder@mail.ru
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Description:
Since regexp are already supported well enough to use in functions like
COUNTIFS, why plain regexp match couldn't be used as a function usable in a
formula?
This would make extraction of a desirable substring simple in most situations
(even with positive/negative lookahead/lookbehind regexps), without either
requiring more custom functions or unnecessarily complication.

Steps to Reproduce:
I want to parse a value out of text â€” e.g. the text in column $I may contain
"SomeTrait[123]" and if so, my goal is to extract value 123. I need a formula
to  fill a long column.

Actual Results:
I'll end up with something like
=IFERROR( FIND("SomeTrait[",$I2),0)
in one column ($Z), and then
=IF($Z2>0,VALUE( MID($I2,$Z2+LEN("SomeTrait["),FIND("]",$I2,
$Z2)-LEN("SomeTrait[")-$Z2) ),0)
in another, and still have to pre- sanitize text so it won't fail due to
containing "Trait [5]" instead, or make it even more complicated.
Every time a string needs parsing, this involves unnecessarily complex
constructs made of LEFT()/MID()/RIGHT(), FIND/SEARCH() and LEN() that have to
either be repeated with the same arguments or consume half a dozen columns as
temporary variables, just to parse this one value (and there are more of them).

Expected Results:
=VALUE(REGEXPMATCH($I2, "(?<=SomeTrait\[).*(?=\])"))
matches "123". Just find the right cell, extract desired text from it, process
it. Two functions, fairly transparent… regexps may be not always quite obvious,
but at least short enough to analyze as a whole, and often easy to manually
test (if something works in search, it will work in a formula too).


Reproducible: Always


User Profile Reset: No



Additional Info:</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>