Ask Your Question
0

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

1 Answer

Sort by » oldest newest most voted
0

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

Comments

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

Stats

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

Seen: 16 times

Last updated: May 12