How can I insert the original matched pattern (OLD STRING) into the result (NEW STRING) Using Microsoft...












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:









share|improve this question


















  • 1





    It sounds like you're asking for ^&, but I don't understand your examples.

    – Scott
    Jan 2 at 3:23
















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:









share|improve this question


















  • 1





    It sounds like you're asking for ^&, but I don't understand your examples.

    – Scott
    Jan 2 at 3:23














0












0








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:









share|improve this question














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:






microsoft-word microsoft-office sed microsoft-word-2016 string-manipulation






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 2 at 2:56









IdleCustardIdleCustard

1031




1031








  • 1





    It sounds like you're asking for ^&, but I don't understand your examples.

    – Scott
    Jan 2 at 3:23














  • 1





    It sounds like you're asking for ^&, but I don't understand your examples.

    – Scott
    Jan 2 at 3:23








1




1





It sounds like you're asking for ^&, but I don't understand your examples.

– Scott
Jan 2 at 3:23





It sounds like you're asking for ^&, but I don't understand your examples.

– Scott
Jan 2 at 3:23










2 Answers
2






active

oldest

votes


















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.






share|improve this answer































    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.






    share|improve this answer























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "3"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1389658%2fhow-can-i-insert-the-original-matched-pattern-old-string-into-the-result-new%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      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.






      share|improve this answer




























        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.






        share|improve this answer


























          0












          0








          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.






          share|improve this answer













          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 3 at 0:03









          Bri.L.MBri.L.M

          1




          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.






              share|improve this answer




























                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.






                share|improve this answer


























                  0












                  0








                  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.






                  share|improve this answer













                  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.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 10 at 3:00









                  TanyaTanya

                  1,19044




                  1,19044






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Super User!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1389658%2fhow-can-i-insert-the-original-matched-pattern-old-string-into-the-result-new%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                      Alcedinidae

                      Origin of the phrase “under your belt”?