• Login
Community
  • Login

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

Scheduled Pinned Locked Moved General Discussion
9 Posts 5 Posters 62.0k 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.
  • A
    Art Kautz
    last edited by Mar 29, 2019, 5:48 PM

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

    1 Reply Last reply Reply Quote 1
    • P
      PeterJones
      last edited by PeterJones Mar 29, 2019, 5:57 PM Mar 29, 2019, 5:56 PM

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

      A 1 Reply Last reply Mar 29, 2019, 8:30 PM Reply Quote 2
      • A
        Alan Kilborn @PeterJones
        last edited by Mar 29, 2019, 8:30 PM

        @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
        • P
          PeterJones
          last edited by Mar 29, 2019, 8:37 PM

          @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
          • G
            guy038
            last edited by Mar 29, 2019, 10:47 PM

            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

            M 1 Reply Last reply Mar 29, 2019, 11:03 PM Reply Quote 3
            • M
              Meta Chuh moderator @guy038
              last edited by Meta Chuh Mar 29, 2019, 11:08 PM Mar 29, 2019, 11:03 PM

              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
              • A
                Alan Kilborn
                last edited by Alan Kilborn Mar 30, 2019, 1:26 AM Mar 30, 2019, 1:25 AM

                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
                • P
                  PeterJones
                  last edited by PeterJones Mar 30, 2019, 5:20 PM Mar 30, 2019, 5:18 PM

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

                  A 1 Reply Last reply Mar 30, 2019, 8:29 PM Reply Quote 2
                  • A
                    Alan Kilborn @PeterJones
                    last edited by Mar 30, 2019, 8:29 PM

                    @PeterJones

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

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