Use a regular expression in searching and replacing ultraedit)

Source: Internet
Author: User
Tags ultraedit

Many of my friends have used or are using ultraedit. This editor has been with me for several years. It has influenced my coding shortcut habits in many places. ultraedit provides a wealth
Editing functions, which are very important for finding and replacing functions. ultraedit provides a convenient and powerful search and replacement function, which can be found and replaced in a single file.
Files and directories. When using these search and replacement functions, we generally use a string for all
A piece of code in the HTML file is searched and replaced, and I don't know how to operate it at once. Because regular expressions are used for long-term programming, I guess the ultraedit with such powerful functions must also have
As expected, ultraedit supports basic regular expression matching and replacement functions, which can meet almost all of our needs.

The following is an example of using a regular expression for searching and replacement in the help of ultraedit.

Ultraedit has two sets of syntax that can be used when using regular expressions for search replacement. An earlier version of ultraedit is used.
Ultraedit
Syntax. The other is a regular expression of the "Unix" type. This set is not enabled in the default configuration of ultraedit. You need to find the search item in the configuration to enable the Unix class.
Regular Expression.

Syntax integration:

Symbol function
% Match the start of a row-show that the search string must start at the row, but does not include any line terminator in the selected result string.
$ Match the end of a row-the search string must be at the end of the row, but the selected result string does not contain any line terminator.
? Match any single character except line breaks
* Except for line breaks that match any number of characters and numbers
+ Match one or more of the previous characters, but at least one
++ The first character matches zero or more characters, but at least one character must appear.
^ B matches a page
^ P matches a linefeed (CR/LF) (segment) (DOS file)
^ R matches a line break (CR only) (segment) (MAC file)
^ N matches a linefeed (lf only) (segment) (UNIX file)
^ T matches a Tab character
[] Match any single character or range in square brackets
^ {A ^} ^ {B ^} matching expression A or B
^ Reload the regular expression character
^ (^) Includes or is marked as the expression used to replace the command.

A regular expression can have a maximum of nine annotation expressions, depending on the needs of regular expressions.
The corresponding replacement expression is ^ X, and the replacement range is 1-9. For example:
If ^ (H * o ^) ^ (F * s ^) matches "Hello folks ",
^ 2 ^ 1 wocould replace it with "folks Hello ".

(Hello folks will be replaced with folks hello .)

Note: ^ is the actual character ^ is not the CTL + key value.

For example:
M? N matches "man", "men", "min", but does not match "moon ".
T * t matches "test", "tonight" and "tea time" (the "Tea t" portion) but does not match "tea"
Time (newline between "tea" and "time ").
Te + st matches "test", "teest", "teeeest", and so on. But does not match "TST ".
[Aeiou] matches each lowercase vowel.
[,.?] Match ",", "." or "?" of a text.
[0-9, A-Z] matches any digit or lowercase letter.
[~ 0-9] matches any character except a number (~ Meaning "no ")

You can search for an expression A or B as follows:

"^ {John ^} ^ {Tom ^ }"

This will appear in John or Tom. There should be nothing between two expressions.

You can combine A or B and C or D in the same search as follows:

"^ {John ^} ^ {Tom ^} ^ {Smith ^} ^ {Jones ^ }"

This will find Smith or Jones behind John or Tom.

Syntax 2: Regular Expressions of the "UNIX" syntax type

Symbol function
/Mark the next character as a special character.
"N" matches the character "N ". "N" is a line break or line break.
^ Match/locate the beginning of the row.
$ Match/locate the end of the row.
* Match the preceding characters zero or multiple times. Example
+ Match the preceding characters once or multiple times. Example
. Match except one line break to match any single character.
(Expression) the expression used to replace the command. A regular expression can have a maximum of 9 annotation expressions as needed. 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 wocould replace it with "Folks hello ".
(Hello folks will be replaced with folks hello .)

[Xyz] A character set. Matches any character between square brackets.
[^ XYZ] A negative character set. Does not match any character between square brackets.
/D matches a numeric character. It is equivalent to [0-9].
/D matches a non-numeric character. It is equivalent to [^ 0-9].
/F matches a new character.
/N matches a newline character.
/R matches a carriage return character.
/S matches any blank space, Tag, or page feed, including spaces, but does not match line breaks.
/S matches any non-blank characters, but does not match line breaks.
/T matches a Tab character.
/V matches a vertical label character.
/W matches any word characters including underscores.
/W matches any non-word characters.
Note: ^ is the actual character ^ is not the CTL + key value.

For example:
M. N matches "man", "men", "min", but does not match "moon ".
T + T matches "test", "tonight" and "tea time" (the "Tea t" portion) but does not match "tea"
Time (newline between "tea" and "time ").
Te * st matches "test", "teest", "teeeest", and so on. But does not match "TST ".
[Aeiou] matches each lowercase vowel.
[,.?] Match ",", "." or "?" of a text.
[0-9, A-Z] matches any digit or lowercase letter.
[^ 0-9] matches any character except a number (~ Meaning "no ")

You can search for an expression A or B as follows:

"(John) | (Tom )"

This will appear in John or Tom. There should be nothing between two expressions.

You can combine A or B and C or D in the same search as follows:

"(John | Tom) (Smith | Jones )"

This will find Smith or Jones behind John or Tom.

In addition:

P matches Cr/LF (same as RN) as DoS row Terminator

If the regular expression is not selected in the search/replace function, the following characters in the replacement field are also valid:

Symbol function

^ Match a "^" Character
^ S is replaced by the selected (highlighted) active file window.
^ C Replace with the clipboard content
^ B matches a page Crack
^ P matches a linefeed (CR/LF) (segment) (DOS file)
^ R matches a line break (CR only) (segment) (MAC file)
^ N matches a linefeed (lf only) (segment) (UNIX file)
^ T matches a Tab character

The following is an example of code replacement.
I want to remove Chinese characters from a. LRC file:

[Ti: 046]
[AR: book I]
[Al: english900]
[LA: zh]
[By:]
[00:00. 00] [4] Identifying objects. Identify an item
[00: 00. 00]
[00: 00. 01] What are these? What are these?
[00:01. 93] Those are books. Those are books.
[00:03. 87] Where are the books? Where are those books?
[. 13] There they are. There.
[00:08. 68] These are my pencils. These are my pencils.
[. 00] Where are your pens? Where are your pens?
[. 85] they're over there. There.
[00:17. 48] Are these your pens? Are these your pens?
[. 04] Yes, they are. It's mine.
[00:22. 63] Those are mine. Those are mine.
[00:25. 39] These are your books, aren't they? These books belong to you, right?
[. 35] No, they aren't. No, no.
[. 07] They're not mine. Not mine.
[00:33. 39] These are mine, and those are yours. These are mine, and those are yours.
[00:35. 57] Those aren't your pens, are they? Those pens are not yours, right?
[00:36. 38]

Click "Search"-> "replace", and select "Regular Expression"

Search: ^ ([/./?] ^ )? ++ $

Replace with: ^ 1

Click "replace all.

You can try the regular expression search and replacement function of ultraedit in future encoding, which is very simple and quick.

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.