Hi, @jos-maas,
Oh yes ! You’re perfectly right. Even, in the example, described in my previous post, we don’t need any alternative !
But, in that case, when a line does not match ( NO group jos ), this line stays unchanged, and we do not need, either, the ELSE part of the conditional replacement !
So, the previous regex S/R, becomes :
SEARCH (?-s)(?<jos>^\d+$)
REPLACE ?{jos}Rewrite $+{jos}, as Group 'jos' exists
And, with the original text :
123
This is a test
4567890
We would get, this time, the text :
Rewrite 123, as Group 'jos' exists
This is a test
Rewrite 4567890, as Group 'jos' exists
Note that, in replacement, the outer parentheses are removed, without any problem !
Jos, for further information, about regular expressions concept and syntax, begin with that article, in N++ Wiki :
http://docs.notepad-plus-plus.org/index.php/Regular_Expressions
In addition, you’ll find good documentation, about the Boost C++ Regex library, v1.55.0 ( similar to the PERL Regular Common Expressions, v1.48.0 ), used by Notepad++, since its 6.0 version, at the TWO addresses below :
http://www.boost.org/doc/libs/1_48_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html
http://www.boost.org/doc/libs/1_48_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html
The FIRST link explains the syntax, of regular expressions, in the SEARCH part
The SECOND link explains the syntax, of regular expressions, in the REPLACEMENT part
You may, also, look for valuable informations, on the sites, below :
http://www.regular-expressions.info ( The reference !! )
http://www.rexegg.com
http://perldoc.perl.org/perlre.html
Be aware that, as any documentation, it may contain some errors ! Anyway, if you detected one, that’s good news : you’re improving ;-)
Cheers,
guy038