Find and replace refinement

how do I search for cells with single char only and not all cells containing that char?
eg, I want to find and replace all cells with only the character b, and not all the cells that contain a b anywhere in it.

With F&R (Ctrl+H) use regular expressions (“RegEx”)
Example:
^c$ will find cells containing the character “c” and nothing else. If “C” (upper case) also is found depends on the setting for “match case”. There are many additional ways to.control the working of RegEx. In the given example ^ means “from start” and $ means “till end”. The c represents a single occurrence of the literal.
A very good tutorial about RegEx is Regular Expression Tutorial - Learn How to Use Regular Expressions.

1 Like

Thanks for responding.
I am not familiar with RegEx.
However, I tried to simply use the find function (ctrl - H) using ^b$ as the argument and I got the same result as just using a simple b. It returned every cell containing anything with a b.

In this case, it’s possible to achieve without regex.
Search for c
Mark the option ‘Entire cells’

2 Likes

This is not the expected behavior.

Thank you Mariosv. That was the simple answer I was seeking.

Another site.

1 Like

Answers by @Mariosv are always valuable.

Nonetheless:

  • The subject of your question used the more general term refinement, and only the content of the question specialized this. If any visitor to this thread (yourself probably) one day is looking for a slightly different kind of refinement, they will need to use RegEx.
  • If the solution I suggested didn’t work for you, the reason probably was that you missed to enable the option Regular expression under “Other options”.
  • As an example you may look for cells containing a “b” preceded by nothing and followed by either a single “c” or nothing. The simple RegEx ^bc?$ can do that. A specialized option for every case of the kind can’t exist.
  • Very few users are familiar with RegEx on a high level. However, many can use the most frequently needed means they provide efficiently. The advanced support for RegEx is one of the relevant advantages of LibreOffice over MS software.
1 Like