Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-15-2020, 12:45 AM
jimmi6jjr jimmi6jjr is offline Formatting text within brackets Windows 10 Formatting text within brackets Office 2019
Novice
Formatting text within brackets
 
Join Date: May 2020
Location: Brisvegas
Posts: 3
jimmi6jjr is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 05-15-2020, 02:00 AM
macropod's Avatar
macropod macropod is offline Formatting text within brackets Windows 7 64bit Formatting text within brackets Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 05-17-2020, 02:00 AM
jimmi6jjr jimmi6jjr is offline Formatting text within brackets Windows 10 Formatting text within brackets Office 2019
Novice
Formatting text within brackets
 
Join Date: May 2020
Location: Brisvegas
Posts: 3
jimmi6jjr is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 05-17-2020, 02:06 AM
macropod's Avatar
macropod macropod is offline Formatting text within brackets Windows 7 64bit Formatting text within brackets Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #5  
Old 10-04-2022, 09:33 PM
jimmi6jjr jimmi6jjr is offline Formatting text within brackets Windows 10 Formatting text within brackets Office 2019
Novice
Formatting text within brackets
 
Join Date: May 2020
Location: Brisvegas
Posts: 3
jimmi6jjr is on a distinguished road
Default

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
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting text within brackets find and delet all text within brackets and the brackets themselves wrdy Word 2 08-03-2017 06:55 PM
Formatting text within brackets 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
Formatting text within brackets 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

Other Forums: Access Forums

All times are GMT -7. The time now is 12:34 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft