Recently, when editing the text, a handy regular replacement function was used for emeditor.
That is, I want to generate another piece of text with the search for part of the content.
For example, the client provided me with a bunch of MySQL scripts to build the primary key, and I wanted to change it to MSSQL's primary key script, which is used here.
--before replacement:ALTER TABLEXXXXADD PRIMARY KEYpk_xxxx (IDASC);--after replacementALTER TABLEXXXXADD CONSTRAINTPk_xxxxPRIMARY KEY CLUSTERED(IDASC);
--Of course, deleting pk_xxxx directly can also conform to MSSQL's syntax, just for example.
Here you can use
Find:
ADD PRIMARY KEY (. *)
To be replaced by:
ADD CONSTRAINT \1 PRIMARY KEY CLUSTERED
Specific rules can refer to EmEditor's regular expression Help documentation: \1-\9
Indicates a back reference-a reference are a reference to a previous sub-expression the has already been matched. The reference is to and the sub-expression matched, not to the expression itself. A back reference consists of the escape character ' \ ' followed by a digit ' 1 ' to ' 9 ', ' \1 ' refers to the first sub-express Ion, "\2" to the second etc. For example, "(a) \1" would capture "a" as the first back reference and match any text "AA". Back references can also is used when using the Replace feature under the Search menu. Use regular expressions to locate a text pattern, and the matching text can is replaced by a specified back reference. For example, "(h) (e)" would find "he", and putting "\1" in the Replace with box would Replace "he" with "H" whereas "\2\1" W Ill replace "he" with "eh".
A handy regular replacement feature for EmEditor