https://bugs.documentfoundation.org/show_bug.cgi?id=172727
Bug ID: 172727
Summary: Make REGEX capture groups available outside REGEX
Product: LibreOffice
Version: unspecified
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: enhancement
Priority: medium
Component: Calc
Assignee: [email protected]
Reporter: [email protected]
The LO-Calc cell parser and execution engine are functionally a low-level
machine where every function call is an operation which must be coded
explicitly by the user like you would in any Assembly Language.
This enhancement request seeks to elevate the cell parcer to a higher level
language. In such a language lexical context and scope become important and
usefully provides shortcuts to be more concise.
Right now, intermediate calculation results are unexploitable by users unless
they occupy a cell in a workbook. Visibility is the strength of spreadsheets,
and there is no such thing as hidden variables whose values are unseen unless
you are willing to work with macros.
For example, to transform the date in the string
A10: "CALL .SOY DEC 15 2023 7.25 SUNOPTA INC OPTION EXPIRATION - EXPIRED"
to ISO 8601 format
B10: "CALL .SOY 2023-12-15 7.25 SUNOPTA INC OPTION EXPIRATION - EXPIRED"
we either delegate the magic to a macro or we must code a cell formula like
B1: "(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC) \d\d \d\d\d\d"
B10: =REGEX(A10,B$1,TEXT(DATEVALUE(REGEX(A10,B$1)),"YYYY-MM-DD"))
It would be great if we could make REGEX capture groups available to general
computation so that the Replacement could use capture groups before they become
part of the final string argument to REGEX.
B10: =REGEX(A10,B$1,TEXT(DATEVALUE("$1","YYYY-MM-DD"))
where $1 has dynamic context within the cell lexical scope, so that $1 here
can't be from a different cell.
This would require deep changes to the cell parser and execution engine, and
split the REGEX function internally into a producer and a consumer of capture
groups.
In this particular formula, we are giving up a little bit of storage for nearly
halving the amount of computationrk the CPU must do.
--
You are receiving this mail because:
You are the assignee for the bug.