EmEditor (text editor) Forum Index Questions and Answers about Macros
replace string in placeholder ($1)? | Register To Post |
| Flat | Previous Topic | Next Topic |
| Poster | Thread |
|---|---|
| Stefan | Posted on: 4/28/2012 5:22 am |
Home away from home ![]() ![]() Joined: 7/14/2008 From: Germany, EU Posts: 263 |
Re: replace string in placeholder ($1)? This is how i see it. Don't know if i am 100% correct.
\n "\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 "$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. Recapitulation 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. . |
| Flat | Previous Topic | Next Topic |
| Subject | Poster | Date |
|---|---|---|
| |
vinc25 | 4/27/2012 10:06 am |
| |
Stefan | 4/28/2012 12:02 am |
| |
vinc25 | 4/28/2012 3:38 am |
| » |
Stefan | 4/28/2012 5:22 am |
| Register To Post | |


