Regular expression matching empty string with lookahead/lookbehind cannot be found

I want to insert a text at all spots that match a specific regular expression. For this I search for a regular expression with a lookahead expression and a lookbehind expression like this:


As the replacement of the search I enter the text I want to insert between abc and def:


I now expect to see abc123def where I had just abcdef before the replacement.

Unfortunately the regular expression does find nothing, even if I have abcdef in my document. It seems that it cannot find an empty string.

This method of search for regular expressions matching empty strings at specific spots is not unusual, and regular expressions in other languages like Python support this:

list(re.finditer(r'(?<=abc)(?=def)', 'abc def abcdef'))
[<re.Match object; span=(11, 11), match=''>]

So this seems to be a bug in LibreOffice (i.e. in a library of course). Or maybe I have to use it differently somehow? I also tried adding empty-string matching expressions like \b or \B between the parentheses, but to no avail.

I could grab the expressions in the lookbehind and lookahead and replace them along:

(abc)(def) → $1123$2 (or similar)

But this would delete abcdef and insert abc123def instead of inserting just 123. Since my changes are recorded (Track changes), this is not what I want, as it clutters things. Instead of inserting a single character, I then replace long words by nearly the same long words, with just one character added, which would be confusing.

File a bug report.

Or rather, CC to tdf#135538.


Thanks for the pointer. So this is a bug which is open and not being worked on for several years.
I will work around it then for now.