• Login
Community
  • Login

Macro to Replace Whole Word

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
7 Posts 2 Posters 343 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.
  • M
    MaximillianM
    last edited by MaximillianM Apr 15, 2023, 10:22 PM Apr 15, 2023, 10:20 PM

    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

    M 1 Reply Last reply Apr 15, 2023, 10:28 PM Reply Quote 0
    • M
      Mark Olson @MaximillianM
      last edited by Mark Olson Apr 15, 2023, 10:31 PM Apr 15, 2023, 10:28 PM

      @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.

      M 3 Replies Last reply Apr 15, 2023, 10:31 PM Reply Quote 2
      • M
        MaximillianM @Mark Olson
        last edited by Apr 15, 2023, 10:31 PM

        This post is deleted!
        M 1 Reply Last reply Apr 15, 2023, 10:37 PM Reply Quote 0
        • M
          MaximillianM @Mark Olson
          last edited by Apr 15, 2023, 10:33 PM

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • M
            MaximillianM @Mark Olson
            last edited by Apr 15, 2023, 10:36 PM

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

            M 1 Reply Last reply Apr 15, 2023, 10:38 PM Reply Quote 0
            • M
              Mark Olson @MaximillianM
              last edited by Apr 15, 2023, 10:37 PM

              @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
              • M
                Mark Olson @MaximillianM
                last edited by Apr 15, 2023, 10:38 PM

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

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