A handy regular replacement feature for EmEditor

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.