Community
    • Login

    Search and replace options \n, \r, \t, \o, \x...

    Scheduled Pinned Locked Moved General Discussion
    9 Posts 5 Posters 61.1k 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.
    • Art KautzA
      Art Kautz
      last edited by

      What are all of these? I discovered that \t was tab, but the others remain a mystery.

      1 Reply Last reply Reply Quote 1
      • PeterJonesP
        PeterJones
        last edited by PeterJones

        @Art-Kautz, Welcome to the Community Forums,

        Those “escape” sequences allow entering special characters in the search/replace dialog (though it’s a \0 backslash+zero, not \o backslash+letter+o)

        They are documented https://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html#boost_regex.syntax.perl_syntax.escapes .

        They are only active when you have the search mode set to Extended or Regular Expression.

        Alan KilbornA 1 Reply Last reply Reply Quote 2
        • Alan KilbornA
          Alan Kilborn @PeterJones
          last edited by

          @PeterJones

          I largely ignore Extended mode. Are all of those the OP mentioned valid there? Are there any real advantages to Ext mode or should I just go back to ignoring it. If you know…

          1 Reply Last reply Reply Quote 1
          • PeterJonesP
            PeterJones
            last edited by

            @Alan-Kilborn said:

            Are all of those the OP mentioned valid there?

            The ones the OP mentioned are the escapes listed in the dialog box for what “Extended mode” is. I never use Extended mode, but I assume if the dialog box mentions those escapes for Extended mode, they are valid for Extended mode.

            Are there any real advantages to Ext mode or should I just go back to ignoring it. If you know…

            From what I understand, it allows you to use characters like ^[].* without their special regex meaning. It might be nice to not have to escape those… but I rarely am searching for special characters, anyway.

            1 Reply Last reply Reply Quote 2
            • guy038G
              guy038
              last edited by

              Hi, @art-kautz, @Peterjones, @alan-kilborn and All,

              Have a look to these two links, below. The first one is a post of mine, two years ago and the second is from the official ( and a bit out of date ! ) N++ documentation :

              https://notepad-plus-plus.org/community/topic/13808/search-replace-of-multiline-text-blocs/2

              http://docs.notepad-plus-plus.org/index.php/Searching_And_Replacing#Escape_sequences_supported_in_extended_mode

              Best Regards,

              guy038

              Meta ChuhM 1 Reply Last reply Reply Quote 3
              • Meta ChuhM
                Meta Chuh moderator @guy038
                last edited by Meta Chuh

                ps to @guy038 :
                omg, an old ion saliu aka parpaluck thread, what a psycho.
                he even really insisted that claudia’s screenshots were all photoshopped.

                1 Reply Last reply Reply Quote 2
                • Alan KilbornA
                  Alan Kilborn
                  last edited by Alan Kilborn

                  From @guy038’s posting (see EITHER hyperlink), it appears it truly is \o and not \0 (sorry, Peter). I guess I will have to remember this the next time I want to express a search in octal, as I don’t believe regex will do octal. In other words, I can promptly forget about this. :)

                  1 Reply Last reply Reply Quote 2
                  • PeterJonesP
                    PeterJones
                    last edited by PeterJones

                    @Alan-Kilborn said:

                    it appears it truly is \o and not \0 (sorry, Peter)

                    I cannot know what the OP intended, but according to the source code, the list of characters in that string in the dialog box includes \0, not \o:

                    • english.xml line 381
                    • english.xml line 981

                    And the outdated docs #Extended Mode say,

                    \0
                              the NUL control character (ASCII 0x00). Not supported in regular expressions - use \x00 instead.

                    Some experiments, with a file that contains multiple 0 characters (and some others), any of the following will find the 0s:

                    • Extended: 0
                    • Extended: \o060
                    • Extended: \x30
                    • Regex: 0
                    • Regex: \060 (no o prefix)
                    • Regex: \x30

                    Similarly, if you have a file that’s got one or more NUL character

                    • Extended: \0
                    • Extended: \o000
                    • Extended: \x00
                    • Regex: \0
                    • Regex: \000
                    • Regex: \x00

                    (So I actually disagree with the docs in this regard: in regex, \0 does match the NUL character. Probably, the docs were written under the older regex engine, not the “most recent” Boost 3.5.6 engine.)

                    Alan KilbornA 1 Reply Last reply Reply Quote 2
                    • Alan KilbornA
                      Alan Kilborn @PeterJones
                      last edited by

                      @PeterJones

                      Ah, okay, so extended mode support both \0 and \o. Good to know.

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