[Libreoffice-bugs] [Bug 123000] New: Regular expression match function, please?

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Sun Jan 27 19:45:15 UTC 2019


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

            Bug ID: 123000
           Summary: Regular expression match function, please?
           Product: LibreOffice
           Version: unspecified
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: medium
         Component: Calc
          Assignee: libreoffice-bugs at lists.freedesktop.org
          Reporter: turbobeholder at mail.ru

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:

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20190127/a975ff53/attachment-0001.html>


More information about the Libreoffice-bugs mailing list