#1
|
|||
|
|||
replace specific text within brackets
Hi
I have no idea where to start with this one (can clear all text within parenthesis no problem but i specifically need to delete as follows) I am looking to delete all text with the following criteria when in parenthesis some start with (formerly ) and some are (formerly John Wilson) with John Wilson being totally random could be any combination up to 25 characters End result - all deleted including parenthesis Any help greatly appreciated Thanks Steve The following works for (formerly ) as above but needing to catch (formerly John Wilson) << John Wilson could be anything random Sub replacetext() Dim test test = "(formerly )" Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = test .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll End Sub Last edited by NoLockdownsLOL; 07-14-2021 at 05:04 PM. |
#2
|
||||
|
||||
Find and replace dialog
Find: \(formerly[a-zA-Z ]{1,25}\) Replace with: leave it empty Tick the Use wildcards checkbox Replace All
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
Thanks Guessed
Works a treat , thanks a million fellow Aussie (i'm in Brisbane) I just found one anomaly, names with an apostrophe for Example D'arcy or similar ? P.S Love the Avatar, Gary Larson The Far Side i was a huge fan back in the day (he retired in 1995!) |
#4
|
||||
|
||||
NoLockdownsLOL - at least it wasn't a dig at State of Origin last night.
You can try adding the apostrophe into the wildcard search box Find: \(formerly[a-zA-Z' ]{1,25}\)
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#5
|
|||
|
|||
well SOO we still have our tails between our legs from the previous smashings lol
re the apostrophe - tried that unsuccessfully , tried some variants w/out luck also |
#6
|
||||
|
||||
Non-wildcard find and replaces don't care about the variants of apostrophes but Wildcard searches do. A dumb quote is only one of the apostrophe types - we also have an opening smart quote, closing smart quote and an official apostrophe. See Replacing Some Smart Quotes (Microsoft Word) for more detail.
You will need to find out what particular apostrophe variant is in play here and enter that by holding the Alt key down and typing 0145 or 0146 or 0147 or 0148. You could cover all the bases by adding all of them.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#7
|
|||
|
|||
Thanks Andrew, good call, will test all the variants .............
Cheers EDIT You could cover all the bases by adding all of them. Did this and worked - boom Legend, thanks for your help Go the lions! |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Enclose All Instances of a Specific Custom Style in Brackets | Matt C | Word VBA | 7 | 05-30-2021 04:52 AM |
find/replace all text not a specific colour? | LQuinn | Word VBA | 3 | 04-06-2021 04:51 PM |
find and delet all text within brackets and the brackets themselves | wrdy | Word | 2 | 08-03-2017 06:55 PM |
Find and Replace - How to insert brackets around all numbers in a doc | Natedogg | Word | 2 | 05-21-2015 07:16 AM |
Find/Replace Brackets Problem | fatso | Word | 2 | 08-04-2011 11:34 AM |