![]() |
|
#1
|
|||
|
|||
|
We have built a script to remove square brackets surrounding numbers, like [2] or [99999], then making the numbers formerly wrapped in square brackets to superscript.
But today, we found we also must remove square brackets from comma-separated numbers, like [2,3] or [2,3,4,5,6,7,8,9,10] I'm trying to do wildcards in find, like this, but this only works for patterns with a single comma. In my .Find.Text attempt, here's what I'm trying to do... - Find a literal open square bracket, - followed by any number, 1 or more times, - group start - followed by a literal comma, 0 or one times, - followed by any number 1 or more times - group end - the above group 0 or more times, - ending with a close square bracket] Code:
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Format = False
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
.Text = "\[[0-9]{1,0}(\,[0-9]{1,0}){,}\]"
.Replacement.Text = ""
End With
Do While .Find.Execute = True
str_found = .Text
str_found = Replace(str_found, "[", "") ' replace open [ bracket with nothing.
str_found = Replace(str_found, "]", "") 'replace close ] bracket with nothing
.Font.Superscript = str_found
.Text = str_found ' Replace the text in doc, now without square [] brackets.
.Collapse wdCollapseEnd
Loop
End With
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Need Wild Card for Deleting Square Brackets with Differing Numbers inside
|
CrossReach | Word | 6 | 11-26-2019 01:02 PM |
| What are the areas in square brackets [ ]? | mummy | Word | 3 | 01-24-2018 05:15 AM |
Bold numbers between square brackets
|
jeffreybrown | Word | 4 | 02-13-2017 04:32 PM |
Help with: Replace and reformat numbers inside square brackets
|
johnbrowny | Word | 1 | 02-13-2016 06:45 PM |
| Gray square brackets | waldux | Word | 8 | 09-25-2013 04:14 PM |