Bug 161271 - Add REGEXTEST, REGEXEXTRACT, REGEXREPLACE functions (look at Comment 3 and 6)
Summary: Add REGEXTEST, REGEXEXTRACT, REGEXREPLACE functions (look at Comment 3 and 6)
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Missed-Excel-Functions
  Show dependency treegraph
 
Reported: 2024-05-25 07:28 UTC by johnks
Modified: 2026-07-05 16:52 UTC (History)
8 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description johnks 2024-05-25 07:28:06 UTC
Description:
https://insider.microsoft365.com/en-us/blog/new-regular-expression-regex-functions-in-excel

excel is introducing these 3 regex formulae  with more regex support in xlookup and xmatch but lets focus on these 3 for now


    REGEXTEST: Checks if any part of supplied text matches a regex pattern.
    REGEXEXTRACT: Extracts one or more parts of supplied text that match a regex pattern.
    REGEXREPLACE: Searches for a regex pattern within supplied text and replaces it with different text.


Steps to Reproduce:
support new excel formulae regarding regex

Actual Results:
formula is missing

Expected Results:
formula should work in calc as it works in excel 


Reproducible: Always


User Profile Reset: No

Additional Info:
Version: 24.2.3.2 (X86_64) / LibreOffice Community
Build ID: 433d9c2ded56988e8a90e6b2e771ee4e6a5ab2ba
CPU threads: 4; OS: Linux 6.5; UI render: default; VCL: gtk3
Locale: en-IN (en_IN); UI: en-US
Calc: threaded
Comment 1 m_a_riosv 2024-05-25 10:47:27 UTC
As always, MS collaborating with the world.

REGEX is available on LibreOffice since 2018 (tdf#113977)

https://help.libreoffice.org/latest/en-US/text/scalc/01/func_regex.html?DbPAR=CALC#bm_id831542233029549
Comment 2 johnks 2024-05-25 11:13:22 UTC
(In reply to m_a_riosv from comment #1)
> As always, MS collaborating with the world.
> 
> REGEX is available on LibreOffice since 2018 (tdf#113977)
> 
> https://help.libreoffice.org/latest/en-US/text/scalc/01/func_regex.
> html?DbPAR=CALC#bm_id831542233029549

i am specifically asking to support windows =regextest and other 2 formulae. 

i know LO has has regex for ages but this isn't a drop in replacement for the new excel formulae or is it?
Comment 3 Eike Rathke (retired, only occasionally showing up) 2024-05-27 10:14:25 UTC
Should be fairly straight forward to implement these functions for interoperability, as each of them covers a limited subset of what REGEX() already does. Care should be taken to not duplicate the implementation four times but factor out the common part(s).

However, results may have to be taken with a grain of salt, if Excel uses a regex engine with different capabilities than ICU regex they may differ, which generally isn't a problem with commonly used regex patterns and features but more sophisticated details.
Comment 4 Heiko Tietze 2024-05-27 12:23:02 UTC
+1 for interoperability

(In reply to Eike Rathke from comment #3)
> Should be fairly straight forward to implement...
Easyhackable?
Comment 5 Eike Rathke (retired, only occasionally showing up) 2024-05-31 13:08:45 UTC
Not really. For new functions too many places need to be touched to get it right.
Comment 6 Werner Tietz 2026-05-02 10:11:59 UTC
(In reply to Heiko Tietze from comment #4)
> +1 for interoperability

 -1 because we don’t have to copy everything »invented« by $MS

> 
> (In reply to Eike Rathke from comment #3)
> > Should be fairly straight forward to implement...
> Easyhackable?

just to remind:
REGEXEXTRACT and REGEXREPLACE is nothing but =REGEX() with different syntax.

REGEXTEST is covered by 

=IFNA(IF(LEN(REGEX(text;regex));1;0);0)
Comment 7 Robert Lacroix 2026-07-05 07:51:24 UTC
-1 (for now). I would refrain from adding a compatible feature into LO-Calc until this really hits the Windows desktop version of Excel. 

I agree in general about interoperability with Excel. However, these functions are generally available only in the cloud and Mac versions, with appearance in Windows as Beta.

It would surprise me for MS to implement a copy of LO-Calc's REGEX, as MS in the past has copied features of the competition in domains where the competition had a substantial market lead which MS could effectively expropriate. That doesn't apply here. Furthermore, Excel product management is more focussed on market leadership than innovation leadership. The risk to reward ratio is too high in the enterprise desktop market, which Windows dominates, for MS to destabilize by gambling with new functionality.

REGEXTEST Function Applies To:
   Excel for Microsoft 365
   Excel for Microsoft 365 for Mac
https://support.microsoft.com/en-us/excel/functions/regextest-function


I prefer the LO-Calc REGEX function anyway, and will shortly be submitting a simple proposal to make it even better.
Comment 8 Robert Lacroix 2026-07-05 16:52:26 UTC
In the meantime, if someone is keen to do it, ask MS Copilot to write a macro for Calc which converts these functions into REGEX, to allow you at least to load and run the Excel workbook in LO-Calc.

You must be very specific about the syntax of REGEX, as Copilot will cheerily give you incorrect code. Depending on your skill, it can take frustratingly many iterations to goad Copilot into creating 100% correct code. However, you can just take what Copilot gives you after a couple of iterations as a pretty solid outline and fix up the details yourself in a fraction of the time.


The result hopefully is a macro which converts these unrecognized functions after loading an Excel workbook into LO-Calc. The trip, however, is one-way. If you want to save this workbook and give it back to Excel you will need to convert REGEX back to Excel syntax, which won't be so easy.

There can't be very much demand for the reverse trip, otherwise we would be seeing requests to convert LO-Calc workbooks into Excel.