Search and replace options \n, \r, \t, \o, \x...
-
What are all of these? I discovered that \t was tab, but the others remain a mystery.
-
@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.
-
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…
-
@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. -
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
Best Regards,
guy038
-
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. -
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. :) -
@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
: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 the0
s:- 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.) - Extended:
-
Ah, okay, so extended mode support both
\0
and\o
. Good to know.