Community
    • Login

    Macro to Replace Whole Word

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    7 Posts 2 Posters 934 Views 1 Watching
    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 Offline
      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 Online
        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 Offline
          MaximillianM @Mark Olson
          last edited by

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

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • MaximillianMM Offline
              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 Online
                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 Online
                  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

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  • First post
                    Last post
                  The Community of users of the Notepad++ text editor.
                  Powered by NodeBB | Contributors