Community
    • Login

    Search++ (\W)'(\w) regex replace failure

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    14 Posts 4 Posters 366 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.
    • Alan KilbornA Offline
      Alan Kilborn @Coises
      last edited by Alan Kilborn

      @Coises said:

      By default, Notepad++ runs in single instance mode. I tried it and it appears that when the Notepad++ you are attempting to open is in single instance mode, if any Notepad++ executable is open, it will switch to it instead. If you open the portable alone, with no other Notepad++ running, and change Settings | Preferences… | Multi-Instance & Date to Always in multi-instance mode, then you’ll be able to open the portable when the installed version is already running.

      I think that rather than mucking with the settings that you already have set the way you want in your main N++, to run a portable alongside it is as simple as adding the -multiInst command line parameter to the invocation of the portable.

      CoisesC 1 Reply Last reply Reply Quote 2
      • CoisesC Online
        Coises @Alan Kilborn
        last edited by

        @Alan-Kilborn said:

        @Coises said:

        By default, Notepad++ runs in single instance mode. I tried it and it appears that when the Notepad++ you are attempting to open is in single instance mode, if any Notepad++ executable is open, it will switch to it instead. If you open the portable alone, with no other Notepad++ running, and change Settings | Preferences… | Multi-Instance & Date to Always in multi-instance mode, then you’ll be able to open the portable when the installed version is already running.

        (emphasis added)

        I think that rather than mucking with the settings that you already have set the way you want in your main N++, to run a portable alongside it is as simple as adding the -multiInst command line parameter to the invocation of the portable.

        I didn’t suggest changing the settings of the installed copy, nor would it help if he did. There’s nothing wrong with your method, either, if he’d rather create a shortcut and/or run from the command line.

        Alan KilbornA 1 Reply Last reply Reply Quote 0
        • Alan KilbornA Offline
          Alan Kilborn @Coises
          last edited by

          @Coises said:

          I didn’t suggest changing the settings of the installed copy

          Gotcha; didn’t catch that on the first read, sorry.

          1 Reply Last reply Reply Quote 0
          • M Andre Z EckenrodeM Offline
            M Andre Z Eckenrode @Coises
            last edited by

            @Coises

            I didn’t experiment with adding or subtracting any plugins (other than having already added Search++) in the portable version yet. but I did just open the portable again, this time via command line and -multiInst, per @Alan-Kilborn’s suggestion (thanks, Alan), while my installed version was already open. I then retried my regex, but this time got anomalous results, such as:

            this
            u’dos I am
            that
            
            this
            ’Round and ’round
            that
            

            I then undid all replacements, and redid them, with all results correct the second time around.

            Quit the portable copy, then reopened it (as -multiInst) again, then redid the regex, with anomalies:

            this
            ’Cos I am
            that
            
            this
            ’Round and-’-ound
            that
            

            Quit the portable copy again, then reopened it (as -multiInst) again, then redid the regex again, with slightly different anomalies:

            this
            ’Cos I am
            that
            
            this
            -’-ound and ’round
            that
            

            Talk about bizarre. But it seems we can rule out conflicts from the other plugins I use in my installed version, unless there’s some way for them (or something else) to cross-contaminate the process in active memory due to the installed version still being open.

            […shuts down both portable and installed versions; reopens portable version; retries regex…]

            Nope. Still had anomalous results:

            this
            ’Cos I am
            that
            
            this
            -’-ound and ’round
            that
            

            I’m out of guesses. It’s hit or miss whether or where or how it happens.

            CoisesC 1 Reply Last reply Reply Quote 1
            • CoisesC Online
              Coises @M Andre Z Eckenrode
              last edited by

              @M-Andre-Z-Eckenrode said:

              I’m out of guesses. It’s hit or miss whether or where or how it happens.

              Thank you for the reports. I don’t know the cause yet either, but I now think it is very likely that it is a fault in my code which I just haven’t encountered yet.

              I notice that the literal ’ is always correct; when something is wrong, it’s the \1 and \2 substitutions. I have a hunch that if you were to show line endings, in the ones where a spurious character appears before a ’ at the beginning of a line the preceding line ending would have lost its LF and become just a lone CR.

              I will work on it. Thank you again for your patience and this information. The reports that it occurred in a clean, portable version are very helpful in that they tell me what it isn’t; with something I can’t readily reproduce, that’s valuable knowledge.

              M Andre Z EckenrodeM 2 Replies Last reply Reply Quote 1
              • M Andre Z EckenrodeM Offline
                M Andre Z Eckenrode @Coises
                last edited by M Andre Z Eckenrode

                @Coises said:

                I notice that the literal ’ is always correct

                Ah, but don’t forget in my initial post, I was sometimes getting question marks (?) instead of ’. When I first saw that, I suspected that maybe Search++ was failing to make the conversion back from UTF to ANSI, since I believe it was previously stated that text is treated internally as UTF, but I was actually working on ANSI text at the time, and a question mark is what I usually get when accidentally trying to paste a UTF character in an ANSI file. But, I guess that’s not the case.

                1 Reply Last reply Reply Quote 1
                • M Andre Z EckenrodeM Offline
                  M Andre Z Eckenrode @Coises
                  last edited by

                  @Coises said:

                  I have a hunch that if you were to show line endings, in the ones where a spurious character appears before a ’ at the beginning of a line the preceding line ending would have lost its LF and become just a lone CR.

                  Here ya go… This is what happened when I just now tried it:

                  2026-08-06 17;39;02 - MAZE - Search++ Regex Replace.png

                  Note that only one CRLF became just LF (line 8), but also that in the case of what you see here as line 5, it’s actually a combination of what were lines 5 and 6 from the pre-replacement text, so an entire CRLF is now missing. I don’t particularly think that’s related to the fact that I had View > Show Symbol > Show End of Line enabled, but what do I know?

                  M Andre Z EckenrodeM 1 Reply Last reply Reply Quote 1
                  • M Andre Z EckenrodeM Offline
                    M Andre Z Eckenrode @M Andre Z Eckenrode
                    last edited by

                    M-Andre-Z-Eckenrode said:

                    Note that only one CRLF became just LF (line 8)

                    Correction: Only one CRLF became just CR.

                    1 Reply Last reply Reply Quote 0
                    • guy038G Offline
                      guy038
                      last edited by

                      Hello, @m-andre-z-eckenrode, @alan-kilborn, @coises, @mpheath, @thomas-knoefel and All,

                      Just an observation : if you modify the proposed replacement :

                      FIND (\W)'(\w)

                      REPLACE \1’\2

                      by this one :

                      FIND (?<=\W)'(?=\w)

                      REPLACE ’

                      No problem occurs for a step by step replacement sequence or a Replace All operation for, either, an ANSI or UTF-8 encoded file. I verified this assumption with four regex engines :

                      • The native Search > Replace dialog of N++

                      • The Plugins > Column++ > Search... dialog

                      • The Plugins > Search++ > Search... dialog

                      • The Plugins > MultiReplace > MultiReplace... dialog


                      May be, this result will help to resolve possible bugs, with the other regex syntaxes

                      Best Regards,

                      guy038

                      CoisesC 1 Reply Last reply Reply Quote 0
                      • CoisesC Online
                        Coises @guy038
                        last edited by

                        @m-andre-z-eckenrode:

                        I’ve been looking, but so far I have not found a potential cause for the results you obtained.

                        @guy038’s post just led me to think of something.

                        The debug information in the post where you asked about the failure to replace in Notepad++ showed that you have Columns++ installed.

                        The search and replace code Search++ uses is derived from what I used in Columns++, but I have made some changes. Would you try and see if you can get the search in Columns++ to misbehave under the same circumstances as the one in Search++? (It’s fine to use the installed version of Notepad++ for this test.)

                        Knowing whether or not the fault also appears in Columns++ could help me narrow the scope of what I could be missing.

                        As always, I understand if you don’t have the time for this sort of thing. Thank you for your observations so far, and many thanks in advance if you are willing to do this additional test.

                        1 Reply Last reply Reply Quote 0

                        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