Use regular Expressions (go) in Find and replace for UltraEdit

Source: Internet
Author: User
Tags ultraedit

A lot of friends have used or are using UltraEdit, this editor accompany me for several years, from a lot of places affect my code to write the shortcut key habits, UltraEdit provides a very rich editing functions, which is very important to find and replace the function must everyone used, UltraEdit provides a convenient and powerful find-and-replace feature that can be used to find replacements in separate files, or to find and replace them in multiple files and directories. When we use these find and replace functions, a LiveJournal tags:ultraedit, the regular expression is for a string, the first two days I want to a directory (including subdirectories) in all the HTML files in a section of code to find and replace, Suddenly do not know how to operate, because the long-term writing procedures used to regular expression, so the conjecture has such a powerful function of the UltraEdit must also have such a similar matching function, so click Help a look, as expected, ultraedit support basic regular expression matching find and replace function, This will satisfy almost all of our needs.

The following is an example of using the Regular Expressions section of the Help for UltraEdit to find replacements, and finally a multi-line code lookup substitution that I used in the first two days.

UltraEdit There are two available syntax collections when you use a regular expression to find and replace. One is the earlier version of UltraEdit that was used in the original UltraEdit syntax. The other is a "UNIX" type of regular expression, which is not enabled in the default configuration of UltraEdit and needs to find the search entry in the configuration, enabling the Unix-type regular expression.

Syntax Set one:

Symbol function
% match start of line-Displays the search string must start at the beginning of the row, but does not include any line-terminating characters in the selected result string.
$ Match Line End-Displays the search string that must be at the end of the line, but does not include any row termination characters in the selected result string.
? Matches any single character other than line break
* matches any number of characters and numbers in addition to line breaks
+ The previous character matches one or more, but at least one
+ + the previous character matches 0 or more, but at least one of the
^b match a paging
^p matches a line break (CR/LF) (segment) (DOS file)
^r matches a line break (CR only) (segment) (MAC file)
^n matches a newline character (LF only) (segment) (UNIX file)
^t matches a label character tab
[] matches any single character, or the range in square brackets
^{a^}^{b^} matches an expression A or B
^ Normal expression characters after overloading
^ (^) Enclose or label an expression that is used to replace a command.

A regular expression can have up to 9 label expressions, which are determined by the need for regular expressions.
The corresponding substitution expression is ^x, and the replacement range x is 1-9. For example:
If ^ (h*o^) ^ (f*s^) matches "Hello folks",
^2 ^1 would replace it with "folks hello".

(Hello folks will be replaced with folks hello.) )

Note: ^ is the actual character ^ is not a 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 the words ",", "." or "?".
[0-9, A-z] matches any digit, or lowercase letter.
[~0-9] matches any character except a number (~ means "no")

You can find an expression A or B as follows:

"^{john^}^{tom^}"

This will be looking for John or Tom to appear. There should be nothing between the 2 expressions.

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

"^{john^}^{tom^}^{smith^}^{jones^}"

This will look for Smith or Jones behind John or Tom.

Syntax two: Regular expressions for "Unix" syntactic types

Symbol function
\ mark the next character as a special character.
"N" matches the character "n". "N" a newline or line break character.
^ The start of the match/anchor line.
$ matches/locates the end of the line.
* match the preceding character 0 or more times. Cases
+ matches the preceding character one or more times. Cases
. Matches any single character except for a line break character.
(expression) Labels an expression that is used to replace a command. A regular expression can have a maximum of 9 label expressions, as needed. The corresponding substitution expression is x, and the range of X is 1-9.
For example:
If (H.*o) (f.*s) matches "Hello folks",
2 1 would 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 characters between square brackets.
\d matches a numeric character. equivalent to [0-9].
\d matches a non-numeric character. equivalent to [^0-9].
\f matches a page break character.
\ nthe matches a newline character.
\ r matches a carriage return character.
\s matches any blank spaces, labels, page breaks, including spaces, and so on, but does not match line breaks.
\s matches any non-whitespace character, but does not match the line break.
\ t matches a label tab character.
\v matches a vertical label character.
\w matches any word character including underscores.
\w matches any non-word character character.
Note: ^ is the actual character ^ is not a 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 the words ",", "." or "?".
[0-9,a-z] matches any digit, or lowercase letter.
[^0-9] matches any character except a number (~ means "no")

You can find an expression A or B as follows:

"(John) | (Tom) "

This will be looking for John or Tom to appear. There should be nothing between the 2 expressions.

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

"(john| Tom) (smith| Jones) "

This will look for Smith or Jones behind John or Tom.

Other than that:

P Match cr/lf (as RN) as a DOS line terminator match

If the Find/Replace function is not selected in the expression, the following characters in the replacement field are also valid:

Symbol function

^^ match a "^" character
^s is replaced by an article that is selected (highlighted) in the active file window.
^c Replace with clipboard contents
^b matches a page crack
^p matches a line break (CR/LF) (segment) (DOS file)
^r matches a line break (CR only) (segment) (MAC file)
^n matches a newline character (LF only) (segment) (UNIX file)
^t matches a tab tab character

Here is an example of a code query substitution that I want to implement
I want to remove the kanji from a. lrc file:

[ti:046]
[Ar:book I]
[al:english900]
[La:zh]
[By:]
[00:00.00] [4] identifying objects. Identifying items
[00:00.00]
[00:00.01] What is these? What are these?
[00:01.93] Those is books. Those are books.
[00:03.87] Where is the books? Where are the books?
[00:06.13] There they is. Over there.
[00:08.68] These is my pencils. These are my pencils.
[00:12] Where is your pens? Where are the pens of yours?
[00:14.85] They ' re over there. Over there.
[00:17.48] Is these your pens? Are these your pens?
[00:20.04] Yes,they is. It's mine.
[00:22.63] Those is mine. Those are mine.
[00:25.39] These is your Books,aren ' t they? These books are yours, aren't they?
[00:28.35] No,they aren ' t. No, it's not.
[00:31.07] They ' re not mine. It's not mine.
[00:33.39] These is mine,and those is yours. These are mine, and those are yours.
[00:35.57] Those aren ' t your pens,are they? Those pens aren't yours, are they?
[00:36.38]

Click "Search", "Replace", select "Regular expression"

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

To be replaced by: ^1

Click "Replace All" to complete.

You can try the UltraEdit regular expression lookup replace function in the future code, very simple and fast

Use regular Expressions (go) in Find and replace for UltraEdit

Related Article

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.