How can I insert the original matched pattern (OLD STRING) into the result (NEW STRING) Using Microsoft Word's Find/Replace Feature?

0

Microsoft Word's find/replace feature seems like it is many-to-one.

Suppose that we have a word document numbers surrounded by parentheses, such as (6)
and we want to remove the parentheses and place a dot at the end, such as 6.

Suppose we open up find/replace. We then enter in the following options:

FIND WHAT:     (^#)
REPLACE WITH:  5. 

The above will have the following effect:

.--------.-------.
| BEFORE | AFTER |
.--------.-------.
| (1)    | 5.    |
.--------.-------.
| (2)    | 5.    |
.--------.-------.
| (3)    | 5.    |
.--------.-------.
| (4)    | 5.    |
.--------.-------.

How can we insert the matched pattern in the output/result?

I want to do something like this:

##             (5)
##             becomes
##             AAAA(5).1234

FIND WHAT:     (^#)
REPLACE WITH:  AAAA^MATCHED_PATTERN.1234

##             AAAA(5).1234
##             becomes  
##             5).1234

FIND WHAT:     AAAA(
REPLACE WITH:   

##             5).1234
##             becomes
##             5.

FIND WHAT:     ).1234
REPLACE WITH:   

IdleCustard

Posted 2019-01-02T02:56:48.380

Reputation: 103

1It sounds like you're asking for ^&, but I don't understand your examples. – Scott – 2019-01-02T03:23:52.540

Answers

0

I don't really understand your examples, so I'm not sure if this is what you're asking, but if you want to make it 5. you would do find (5) replace with 5.

Bri.L.M

Posted 2019-01-02T02:56:48.380

Reputation: 1

0

Rather than separate find and replaces as shown in your example above to delete the brackets, you can instead do a wildcard find and replace. The trick is to separate out the parts - for the find, the first part is the opening round bracket, the second part is any digit(s), and the third part is the closing round bracket. Then in your replace, you just keep the second part and add the full stop.

A part in the find is enclosed in round brackets.

For the "range" of characters to search for, enclose them in the square brackets.

The / is to "escape" the special character so you can search for the opening and closing round brackets.

So the find is: ([/(])([0-9]@)([/)]) And the replace is: \2.

Remember to select the option for Use wildcards.

This will find (5) or (11) for example, and replace with 5. and 11. respectively.

Tanya

Posted 2019-01-02T02:56:48.380

Reputation: 1 400