Tips for replacing ultraedit Regular Expression search

Source: Internet
Author: User
Tags expression engine ultraedit

To modify the content of the LDF file exported by admodfy, as shown in the following example:

 

DN: Cn = Cai Ni, ou = aD import ou, Dc = mydomain, Dc = com, Dc = Cn
Changetype: add
Objectclass: Contact
CN: Cai Ni
SN: Cai Ni
Mailnickname: Lily. Cai
Targetaddress: lily.cai@myDomain.com.cn
Proxyaddresses: x400: c = US; A =; P = mydomain; O = exchange; S = Lily. Cai;
Proxyaddresses: SMTP: lily.cai@myDomain.com.cn
Mail: lilycai@myDomain.com.cn
Company: Headquarters
Department: Finance
Displayname: Cai ni [Lily]
Name: Cai Ni
Profilepath:/servernameuserconf $ Lily. Cai

 

Change

 

DN: Cn = Cai Ni, ou = aD import ou, Dc = mydomain, Dc = com, Dc = Cn
Changetype: add
Objectclass: Contact
CN: Cai Ni
SN: Cai Ni
Mailnickname: Lily. Cai
Targetaddress: SMTP: lily.cai@myDomain.com.cn
Proxyaddresses: SMTP: lily.cai@myDomain.com.cn
Mail: lily.cai@myDomain.com.cn
Company: Headquarters
Department: Finance
Displayname: Cai ni [Lily]
Name: Cai Ni

 

To delete the rows that contain the x400 email address and the profilepath, it is unrealistic to manually delete the lines because there are a large number of users in the text. Therefore, you can use the ultraedit regular expression to search and delete the lines. The problem is quickly solved, use ultraedit to open the text. First, select the regular expression engine from the menu. The branch of the Regular Expression Engine is located under "configuration-search" and has the following options:

Perl Compatible Regular Expressions
If this option is selected, the editor uses a Perl-style regular expression based on the boost C ++ Library (when the regular expression is selected in the search/replace dialog box ).

Ultraedit Regular Expression
If this option is selected, the editor selects the regular expression in the search/replace dialog box and uses the regular expression in the ultraedit style.

UNIX Regular Expression
If this option is selected, the editor uses a Unix-style regular expression when selecting a regular expression in the search/replace dialog box.

Select your preferred regular expression type. Different engines have different syntaxes, such as Perl-Compatible Regular Expressions. Press enter to be/R, the ultraedit-style and Unix-compatible carriage returns are ^ P and/N, respectively. The following describes the ultraedit-style carriage returns.

After selecting the style, start searching. In the CTRL + R pop-up replacement dialog box, select "Regular Expression", enter * x400 * ^ P in the search content, and replace it with null, after you click "replace all", all rows containing the x400 are deleted.

Appendix:

Regular Expression (ultraedit syntax ):
 
% Match the first line-indicates that the search string must start with the line, but does not include the row termination characters in any selected result characters.
 
$ Match the end of a line-indicates that the search string must be at the end of the line, but does not include the row termination character in any selected result character.
 
? Match any character except the line break.
 
* Match any number of characters except line breaks.
 
+ Match one or more previous characters/expressions. At least one character must be found. Duplicate line breaks are not matched.
 
+ 0 or multiple times match the previous character/expression. Duplicate line breaks are not matched.
 
^ B matches a paging character.
 
^ P matches a linefeed (CR/LF) (Section) (DOS file)
 
^ R matches a line break (CR only) (Section) (MAC file)
 
^ N matches a linefeed (lf only) (Section) (UNIX file)
 
^ T matches a tab
 
[] Match a single character or range in any parentheses
 
^ {A ^} ^ {B ^} matching expression A or B
 
^ Ignore the subsequent regular expression characters
 
^ (* ^) Add parentheses or tags in the expression to use in the replacement command. There can be 9 expression tags in a regular expression, and numbers are determined based on their order in the regular expression.

The corresponding replacement expression is ^ X, and the range of X is 1-9. For example, if ^ (H * o ^) ^ (F * s ^) matches "Hello folks", ^ 2 ^ 1 indicates that it will be replaced with "Folks hello.

 

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.