2

In LiberOffice Calc, I would like to replace multiple occurences of a character with a single occurence. For example, abcd::::xyz should be replaced with abcd:xyz. How to do that? Thanks in advance.

PS Nayak
  • 143
  • 4
  • Make a copy of the document before you try this out just in case it doesn't work how you want it to. Does this answer your question? [(LibreOffice) Replace every character in a selection with \*](https://askubuntu.com/questions/1391158/libreoffice-replace-every-character-in-a-selection-with) – mchid May 26 '22 at 01:30
  • @mchid I'm afraid not. The solution replaces every character with a replacing character. It does not diminish the occurrence count to 1. – PS Nayak May 26 '22 at 03:23
  • The answer is below. – mchid May 26 '22 at 05:51

2 Answers2

1

Go to Edit > Find and Replace. Make sure Regular Expressions is checked.

  • Find (.)\1+
  • Replace $1

Explanation: (.) finds any character and remembers what it is. \1 refers to whatever character was found originally, and + requires 1 or more of them. $1 also refers to that same character.

Example: apple bannanna becomes aple banana

To change only semicolons, do this instead:

  • Find (:){2,}
  • Replace $1

Documentation: https://help.libreoffice.org/latest/en-US/text/shared/01/02100001.html

Jim K
  • 1,403
  • 10
  • 14
0

On your top menu, click on EDIT.

Then, select Find & Replace.

In the Find field, enter ::::

In the Replace field, enter :

Then, click Replace All.

Finally, click Done and then click Close

mchid
  • 42,315
  • 7
  • 94
  • 147