Re: [libreoffice-users] Find all within brackets
At 20:49 10/09/2020 +0100, Séamas Ó Brógáin wrote: Thank you (once again), Brian. I'll test all this in the morning. What I'm trying to achieve is to select all the terms inside the brackets and then in one fell swoop (1) to change them all to italic (and therefore excluding the brackets) and (2) to change the language of the text within the brackets to a different one from the main text. I'll do it all manually if necessary, but there are an awful lot of them! No need. First use \[[^]]*\] and Find All to select all the bracketed phrases. Then apply italics and the change of language. Then search for [|] (meaning open bracket or close bracket) and again Find All to select all brackets. Now undo italics and (if it matters) reset the language for the brackets themselves. I trust this helps. Brian Barker -- To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/ Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette List archive: https://listarchives.libreoffice.org/global/users/ Privacy Policy: https://www.documentfoundation.org/privacy
Re: [libreoffice-users] Find all within brackets
Interesting question, Seamas. I found a reference here https://stackoverflow.com/a/27225148 and tried that on LibreOffice Writer 6.4 and it seems it works: (?<=\[).+?(?=\]) It can find your "[thus]" without the brackets. -- To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/ Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette List archive: https://listarchives.libreoffice.org/global/users/ Privacy Policy: https://www.documentfoundation.org/privacy
Re: [libreoffice-users] Find all within brackets
At 18:42 10/09/2020 +0100, Séamas Ó Brógáin wrote: Some time ago Brian Barker provided a brilliant formula for finding all text between less-than and greater-than signs, namely <[^>]*> I've been trying to adapt it to finding text within brackets [thus], but without success. I know that brackets as such, as distinct from regular expressions, are identified as \[ and \]; so the formula I've come up with is \[[^>]*\] Unfortunately there are two things wrong with this: (1) it finds all text until a later closing bracket (seemingly the last one in the same paragraph) but not necessarily the immediately following one, ... That central greater-than sign also needs to become a close bracket: \[[^]]*\] ... and (2) the selection includes the brackets themselves, whereas I only want the text that they enclose. Am I attempting the impossible? Yes and no. I don't see how you can match something that then doesn't include parts of the pattern. (Others may know better.) But there are things you can do: o If you want to replace what is contained in the brackets but not the brackets themselves, you can reinsert them in the "Replace with" string, as "[something-else]" (no quotes). o You can mark the brackets and their contents separately - using parentheses - and then use the parts in the replacement. Use (\[)[^]]*(\]) and then "$1something-else$2" (no quotes) in the replacement. "$1" refers to the first parenthesised part and "$2" to the second - in this case the brackets themselves. o Another technique would be to match the entire string, including the brackets, do what you want with that, and then perform another Find & Replace to correct the unwanted effect on the brackets. One idea might be to include additional brackets in the replacement, so that the result would be "[[something-else]]". Then it would be a simple task to search for those double brackets and do whatever was required. It's difficult to be more precise without knowing exactly what you are trying to achieve. I trust this helps. Brian Barker -- To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/ Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette List archive: https://listarchives.libreoffice.org/global/users/ Privacy Policy: https://www.documentfoundation.org/privacy
Re: [libreoffice-users] Find all within brackets
Thank you (once again), Brian. I’l test all this in the morning. What I’m trying to achieve is to select all the terms inside the brackets and then in one fell swoop (1) to change them all to italic (and therefore excluding the brackets) and (2) to change the language of the text within the brackets to a different one from the main text. I’ll do it all manually if necessary, but there are an awful lot of them! S. -- -- To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/ Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette List archive: https://listarchives.libreoffice.org/global/users/ Privacy Policy: https://www.documentfoundation.org/privacy
[libreoffice-users] Find all within brackets
Some time ago Brian Barker provided a brilliant formula for finding all text between less-than and greater-than signs, namely <[^>]*> I’ve been trying to adapt it to finding text within brackets [thus], but without success. I know that brackets as such, as distinct from regular expressions, are identified as \[ and \]; so the formula I’ve come up with is \[[^>]*\] Unfortunately there are two things wrong with this: (1) it finds all text until a later closing bracket (seemingly the last one in the same paragraph) but not necessarily the immediately following one, and (2) the selection includes the brackets themselves, whereas I only want the text that they enclose. Am I attempting the impossible? Any help gratefully received. -- To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/ Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette List archive: https://listarchives.libreoffice.org/global/users/ Privacy Policy: https://www.documentfoundation.org/privacy