Regular expressions do not work in Calc

I’ve been trying to use regular expressions in Calc (LO version 7.2.3.2 x64) and none of them seem to work. I use Find And Replace often and regular expressions would make some things much faster. I can’t even get * to match anything, I just get the message that there are no matches over and over again whenever I use a regular expression. I’ve checked the regular expression box in the dialog.
I’ve used regular expressions for years in other places so I know how they work. This appears to be some kind of fundamental problem like a setting or a missing library. I will be forever in debt to anyone who can solve this.

Everything works. I need more information.
Regexes
@LeroyG’s right: * Match 0 or more times. Match as many times as possible.

You mention Find and Replace; are you sure that its Search in (which is Formula by default) makes sense for the search? E.g., you could use a formula like =1+2, and search for 3, which would not be found legitimately when formulas are searched.

And indeed, without a specific document sample, and a specific search pattern that doesn’t work for you, there’s nothing for others to see, and difficult to guess, when crystal balls got unreliable novadays.

1 Like

I had to select Value instead of Formula on Find-and-Replace dialog in the lower right corner. I don’t see why these need to be distinct why can’t the code handle whatever is in the Cell? What if I want to search for something in regardless of whether it’s a Formula or Value, I either have to repeat the search or change Options - View and check the formulas box (which really shouldn’t be global, it should be per sheet or per selections IMO).

I still have trouble with special characters like " or ’ or ? when I want to put them in my search I’ve tried escaping them with \ but it doesn’t work. I’ve had the same problem with other non-alphanumerics. If you can show me an example of how to do this it would be extremely helpful and will be call you a guru.

Thanks,
Ken

Find: \" or \' or \?

Unfortunately, you haven’t addressed my concern above:

So since you haven’t provided a sample cell content, and your sample search pattern you attempted, there’s nothing to add to the documentation links provided by @LeroyG and @erAck .

What’s what “is in the cell”? Inevitably we need to distinguish the content from what’s displayed.

Actually, by default (option Formula), F&R handles the content of the cell - and that’s the formula in case of a formula cell.

If the cell is containing a number or a text which are entered (keyboard / paste) directly, this content is scanned even if not actually being a formulaPS.

If there actually is a formula and no rarely used option is enabled, the cell does not display the formula, but its result, and searching for occuring strings or RegEx matches in the formula and in its displayed result at the same time wouldn’t make sense in any realistic case. .

PS: For more “techy” readers: In fact the representation you woiuld get shown in the formula bar is searched then because this is what internally is stored in a .FormulaLocal property For “ordinary” numbers with explicit fomatting to fewer decimals there may occur a kind of confusion.
Study
disask78095littleConfusion.ods (30.4 KB)
to see what I’m talking of.

1 Like

Not * but .

See LibreOffice Help on Regular Expressions.

EDIT: ICU Regular Expressions.

And if you want to use only * for any number of any characters then it’s not regular expressions but Wildcards. See also Using Wildcards in Formulas for the definition of ? and * and ~.

1 Like