Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


At 16:55 07/11/2013 +1300, Steve Edmonds wrote:
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


--
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.