This is how i see it. Don’t know if i am 100\% correct.
“n” are RegEx METACHARs from the old UNIX days with his SED and GREP tools.
“1” e.g. will give back what is matched by the expression
enclosed in the first set of parentheses (counted from the left)
“n” are used for a backreference within an search pattern.
E.g. to match double chars like “(.)1” to match “support”.
That way the search pattern is extended by the way
with the match of the expression to find it two times.
“n” can also be used to refer to an match in the find
AFTER it is done, for an use in the replacement like
Find: “(d)” Replace: “the number is 1”
“$n” OTOH was introduced by Perl and is an VARIABLE
which holds the match of an expression after the find is done.
“$n” can be seen here as an synonym of “n”. But only in the replacement.
This days it seems to depend of the used regex engine (or maybe on the coder of the app?)
which flavor is used to represents an backreference
in the REPLACEMENT: 1 or $1 can be used.
But for the backreference in the SEARCH string i think always 1 is used.
It seams EmEditor (using the Boost library) does the same.
1 is allowed in the FIND only (no $1 here)
but 1 AND $1 are both allowed in the replacement field.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.
Share with friends...
Download and experience the “World's fastest text editor” now!