#1
|
|||
|
|||
Formatting text within brackets
I'm trying to format text within square brackets.
Using "\[*\]" is what I usually use to select text within brackets, but it is limited in that it will only find the first closing bracket. Where there are brackets within brackets, it comes up short, e.g.: with "[brown [fox] jumped]" the selection will end at the bracket after fox. I want the selection to end at the final close bracket after jumped. Don't suppose anyone has a quick way of selecting all the text within open bracket until the close bracket? Cheers Last edited by Charles Kenyon; 05-15-2020 at 12:20 PM. Reason: Change title to give better info about question |
#2
|
||||
|
||||
To get the inner pair:
Find = \[[!\[]@\] To get the outer pair as well: Find = \[[!\]]@\[[!\[]@\][!\[]@\] Although asterisks can be used instead, they're liable to return an unbalanced match if there's yet another level.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Thanks - that finds the end of 2 sets of brackets - but didn't seem to work for more than 2?
Don't suppose you know how to select from the first open bracket to the last close bracket? Cheers |
#4
|
||||
|
||||
With Find/Replace you need to build a Find expression that will exclusively identify the number of sets of nested brackets you're interested in, just as I've shown how to do for one and two sets. Otherwise you need a macro. To see what's involved with that, check out the Do While loops in the Convert Text Representations of Fields to Working Fields macro in the Mailmerge Tips and Tricks 'Sticky' thread at the top of the Mailmerge forum: https://www.msofficeforums.com/mail-...ps-tricks.html
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
My god - has it been two years already!
I didn't say thanks for this. I couldn't for the life of me figure out how to create a macro from that one, but thanks heaps for trying to point me in the right direction. thanks mate. cheers |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
find and delet all text within brackets and the brackets themselves | wrdy | Word | 2 | 08-03-2017 06:55 PM |
Selecting text | kirkm | Word | 2 | 09-18-2016 06:23 PM |
Selecting and moving text boxes identified by specific text. | Chayes | Word VBA | 8 | 02-22-2016 07:01 AM |
Word 2003 Brackets appear around copied text | barrage | Word | 1 | 12-16-2015 02:59 PM |
Microsoft Word macro to find text, select all text between brackets, and delete | helal1990 | Word VBA | 4 | 02-05-2015 03:52 PM |