Ask Your Question

Is it possible to use a regular expression in the Replace box in LibreOffice Calc?

asked 2019-05-12 12:14:07 +0200

Sadi gravatar image

This question has been asked several times in the past with no answer to date. It seems actually there's an unresolved issue in LibreOffice Calc that prevents using regular expressions in the Replace box. For instance, you can enter regex codes for tabs, spaces, linefeeds, etc. (\t, \s, \n) in the Find box but you cannot use them in the Replace box - they are treated literally. Any ideas or suggestions?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2020-03-31 19:10:15 +0200

LuisJS gravatar image

I have the same problem on Ubuntu 19.10

The character $ detects the end of paragraphs but \n or \t don't work in Find or Replace.

edit flag offensive delete link more


Please do not use the Answer field for comments that are not an answer to the original question, use add a comment instead. Thanks.

erAck gravatar imageerAck ( 2020-03-31 19:19:18 +0200 )edit

answered 2019-05-12 12:55:00 +0200

No it is not possible; and using regular expressions in replacement field actually does not make sense: regular expression is a mask that should match something in searched text - something not suitable for replacement text. It doesn't make sense to use \s there (meaning "insert unspesified spacing character"). It is possible to use \n and back references, though.

What you are asking about is not using regular expressions in replacement field - but rather having ways to express some specific characters there that have dedicated syntax in regular expressions, like unicode codepoints, but aren't accepted in replace field. You are welcome to file an enhancement request.

edit flag offensive delete link more


See bug report (enhancement request) tdf#106137.

Lupp gravatar imageLupp ( 2019-05-12 14:16:45 +0200 )edit

But of course certain regexp can be used in the replace box and they appear to work in calc. e.g. "&" might be useful.The help page tells you which ones work.

Pansmanser gravatar imagePansmanser ( 2019-05-12 18:54:08 +0200 )edit

"&" isn't a special character for RegeEx. It's one of the "special characters" introduced only for the replace string. In addition (afaik) the special usage of the character "$" followed by a decimal digit in OO/LibO is rather uncommon. Mostly the backslash is used in this role like in back-references to groups found in RegEx. The usage of "$" for "end of text" (text being a paragraph in this context in OO) in the search sting also seems to be uncommon. AltSearch uses "\p" for the purpose which seems more "intuitive" to me. To use "$" in the two mentioned very different roles i would consider definitely a bad idea. Even worse is "\n" inserting a paragraph break if used in the replace string.

Lupp gravatar imageLupp ( 2019-05-12 19:40:13 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2019-05-12 12:14:07 +0200

Seen: 1,898 times

Last updated: Mar 31