Community
    • Login

    Macro to Replace Whole Word

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    7 Posts 2 Posters 331 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • MaximillianMM
      MaximillianM
      last edited by MaximillianM

      Hi, I recorded a macro using Find and Replace to remove a whole word, (the word “um”) but when I run the macro it finds all occurrences of “um” in all words. When I recorded the macro I checked “whole words only” but it didn’t change the text in the macro. I then tried using Regex \bum\b which works in the Find/Replace box. I see that using Regex caused the message=“1625” line to up to to 2 in the macro, but the macro still finds all instances, not just whole words.

      Could you see what I’m doing incorrectly?

      <Action type=“3” message=“1700” wParam=“0” lParam=“0” sParam=“” />
      <Action type=“3” message=“1601” wParam=“0” lParam=“0” sParam=“\bum\b” />
      <Action type=“3” message=“1625” wParam=“0” lParam=“2” sParam=“” />
      <Action type=“3” message=“1602” wParam=“0” lParam=“0” sParam=“” />
      <Action type=“3” message=“1702” wParam=“0” lParam=“768” sParam=“” />
      <Action type=“3” message=“1701” wParam=“0” lParam=“1609” sParam=“” />

      The sample text “um” I want to replace but not the um in number.

      0:09:55.380,0:09:58.980
      um

      0:09:57.240,0:10:01.980
      number 10

      Thanks for your help

      Mark OlsonM 1 Reply Last reply Reply Quote 0
      • Mark OlsonM
        Mark Olson @MaximillianM
        last edited by Mark Olson

        @MaximillianM
        does case matter? e.g., do you want to find UM and Um and uM in addition to um?

        In any case, it’s very strange that regex-replacing \bum\b doesn’t work for you. I was able to record and save a macro regex-replacing \bum\b with nothing, and it worked find for me.

        MaximillianMM 3 Replies Last reply Reply Quote 2
        • MaximillianMM
          MaximillianM @Mark Olson
          last edited by

          This post is deleted!
          Mark OlsonM 1 Reply Last reply Reply Quote 0
          • MaximillianMM
            MaximillianM @Mark Olson
            last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • MaximillianMM
              MaximillianM @Mark Olson
              last edited by

              @Mark-Olson Thanks for your help. I rebooted my computer and now it works.

              Mark OlsonM 1 Reply Last reply Reply Quote 0
              • Mark OlsonM
                Mark Olson @MaximillianM
                last edited by

                @MaximillianM
                Yes, my macro code is exactly the same.
                BTW, please wrap code like XML in a code block like so:
                ``` (triple backticks)
                code here
                more code
                ```
                so that it renders like this

                code here
                more code
                
                1 Reply Last reply Reply Quote 0
                • Mark OlsonM
                  Mark Olson @MaximillianM
                  last edited by

                  @MaximillianM
                  Glad it’s working now! Very strange that you were having this problem.

                  1 Reply Last reply Reply Quote 1
                  • First post
                    Last post
                  The Community of users of the Notepad++ text editor.
                  Powered by NodeBB | Contributors