I am trying to find and replace some text with regex in calc. Can anyone help with how I make it non-greedy.
I think the answer is that you don't: you must find a way of constructing a suitable expression despite such expressions being greedy.
I tried \([:digit:].*?[:digit:]\) in place of \([:digit:].*[:digit:]\) but both are greedy. When the following (12-34-23) cat (233) is in a selected cell it replaces both instances between ().
By the way, I don't understand your ".*?" - do you perhaps mean either ".*" or ".?" ?
I'm afraid you've fallen into the common trap of attempting to define your problem by quoting only expressions that *don't* work! Which parenthesised string do you want to match? I'm guessing the first. But what exactly are the characteristics of the strings you want to match? And the ones you want not to match?
Is the target string always at the beginning? Try:
\<\([^\)]*\)
Is the target string always digits-hyphen-digits-hyphen-digits? Try:
\([:digit:]+-[:digit:]+-[:digit:]+\)
or:
\(\d+-\d+-\d+\)
Do you want to match the second string instead? Try:
\([:digit:]+\)
or:
\(\d+\)
Depending on exactly what you want to match and to avoid matching, you may have to do something different.
I trust this helps.
Brian Barker