Using regular expressions in UltraEdit

Source: Internet
Author: User
Tags expression engine ultraedit

Regular Expressions (UltraEdit Syntax):
% Match Beginning-Indicates that the string to be searched must be at the beginning of the line.
$ Match Line End-indicates that the string to be searched must be at the end of the row
? Matches any single character except for the line break.
* Any number of characters that match any number of occurrences (not including line breaks)
+ Match leading character or expression appears one or more times (excluding line breaks)
+ + matches leading character or expression does not appear or appears more than once (does not include line breaks)
^b Match page Break character
^p line breaks that match a DOS file
^r match line breaks for Mac files (CR only)
^n line break matching UNIX files (LF only)
^t Match a tab
[] matches a single character in square brackets


Delete empty line: Replace%[^t]++^p as empty string

Delete line trailing space: replace [^t]+$ to empty string]

Remove line start space: Replace%[^t]+ as empty string

Each line is set to start with a fixed 4 spaces: replace%[^t]++^ ([~ ^t^p]^) to "^1"

Each paragraph is set to start with a fixed 4 spaces: replace%[^t]+ as ""
(If a line starts with a space, it is considered a beginning line)

Merge a segment into one line: replace [^t]++^p^ ([~ ^t^p]^] with ^1
(Note: This assumes that the text is a DOS return line wrap-CR/LF)

Remove HTML TAG: replace ^{<*>^}^{<*^p*>^} as empty string

Delete all <a&gt in HTML;: Replace <[]++a *[]++href[]++=*> as empty string

Delete the first 2 columns of characters specified in the text: replace%?? is an empty string

Insert a 2-column white space character after the 4th column: replace%^ (???? ^) ^ (^) for "^1 ^2"

Find all the numbers: [0-9]+[.] ++[0-9]+

Find all the words: [a-z]+

Find all URLs: http://[a-z0-9^~ ' _./^-^? =&]+

Note: You need to check the use regular expression option when replacing
Using the UltraEdit style in the regular expression engine in the UltraEdit configuration, the 13 version uses UNIX style to not use the regular Expression grouping feature

From Ultraedit8.0 has been used to now, feel this stuff really good. Some of the basic experience is summarized as follows, share with you, welcome friends who are interested to come to supplement.

Tip 0: How to use ultraedit effectively without a registration code?
Many people immediately think of the use of the crack version, can be actually investigated, it is illegal things. In fact, UltraEdit did not completely block the path. We can use a few tricks to block out the problem. To modify the UltraEdit shortcut, change the command line to: E:uedit9uedit32.exe P:, where P: must be a sub-drive that does not exist on your machine, so there will be no question of the end of the trial time.

Tip 1: How do I get rid of the lines in the edited text that contain a particular string?
This technique is mentioned in the UltraEdit help file. Ctrl+r The Replace window, select Use regular expression, and then replace the empty content with the Find%* your string *^p. For example, I currently have a text file that needs to be stripped of all rows containing the http://www.baidu.net/string, looking for %*http://www.baidu.net/*^p can be replaced by empty. Note that ^p is a line break for the DOS file type. If it is a Unix type file, use ^n.

Tip 2: How to add specific characters at the end of a line, such as commas?
With the above experience (actually I learned from my colleague for the first time), ctrl+r the Replace window and select "Use Regular expression". You can then find ^p (or ^n, if it's a UNIX file), with, ^p (or, ^n) "Replace All" Add a point, if it is a MAC (Apple) type file, the line break symbol is ^r.

Tip 3: How do I delete empty lines?
Refer to the above two examples to find ^p$ and then replace with empty.
It seems that regular expressions need to be studied.

Tip 4: How to edit a file to add a timestamp?
F7 shortcut keys. You try?

Tip 5: Why is the copy/paste (Paste) feature not available?
Not afraid of everyone jokes, I have a few times using the UltraEdit process found that the copy and paste content is not matched. Do not know why, simply restarted the notebook. It dawned on the manual today: UltraEdit has 10 shear plates (clipboard), respectively, with ctrl+0-ctrl+9 switch. Ctrl+0 is Windows, others are user-defined. I was in the process of using the wrong call to CTRL + N, the results of the content is a problem. Have you ever met?

Tip 6: Is there a delay even when you open a small file?
This is the problem I have encountered. Each time a file is opened, there is a delay of several seconds. My machine performance is not bad. What's going on? Network printer get a ghost! Open advanced, Settings, editor, advanced to see if "Load/restore printer settings" is selected? If so, remove (different versions/Han or not may be the location where there is a difference).

Tip 7: Delete the current line contents ctrl+e

TIP 8: You click the shortcut alt+c try it, change to the column editing mode, you can enter multi-line content at once, as long as you choose the line range, editing neat data table is very suitable.

TIP 9: The cursor is located in a row, press Ctrl+f2 to try, with the label, more than a few, hold down the F2, it will go to the tag you set jump to jump, very fun.

Tip 10: For the time being, I'm interested to come and add.
More content in the finishing ...

--How to configure the Java compiler and run instructions in UltraEdit:

Method: In the advanced--Tool Configuration Menu dialog box
1, Configuration Javac
Type in command line: C:jdk1.3binjavac%f
Note: Here the Javac path you want to specify according to your own,%f refers to the current active document full-text name, that is, "file name. Extension",
Because the Java program must be compiled with an extension. If you use%f (uppercase) is wrong, it only represents the file name without the extension
(This is the case for Java run commands). In menu Item Name, enter Javac, which appears in the menus so that you know it is
Used to compile the. Then select the Output to list box and capture output so that you can compile the error in the source code
You see an error message in the Output window below.
2. Configure Java Run command without parameters
In command line input: Java%n, or Java%F, these two are sometimes different, see how your environment is configured, I am using the previous one.
In menu Item Name, enter: Java-no parameter
and select the Output to list box and capture output so that when running, the results of the run are displayed in the Output window.
3. Configure Java Run command with parameters
Type in command line: Java%n%modify%
In menu Item Name, enter: Java-parameter, so that when you run it, it will have a dialog asking you to enter parameters

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. While we are using these search and replace function, is generally for a string, the first two days I want to a directory (including subdirectories) of all the HTML files in a section of the code to find and replace, suddenly do not know how to operate, because long-term writing procedures used in regular expressions, So it is assumed that such a powerful function of the ultraedit must have such a similar matching function, so click on Help to see, as expected, ultraedit support basic regular expression matching find and replace function, which can meet our almost all 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
There is a piece of code that is distributed across HTML files

Copy CodeThe code is as follows:
<!--Copyright 2005. Toplee LTD--
<style>
a.applink:hover {border:2px dotted #DCE6F4;p Adding:2px;color:green;text-decoration:none}
A.applink {border:2px dotted #DCE6F4;p adding:2px;color: #2F5BFF; Background:transparent;text-decoration:none}
a.info {color: #2F5BFF; Background:transparent;text-decoration:none}
A.info:hover {Color:green;background:transparent;text-decoration:underline}
</style>
<div style= ' border:1px solid #DCE6F4; margin-top:20px; margin-bottom:20px; margin-left:5px;
.... Omit several lines ....
<!--/copyright? 2005. Toplee LTD--


I'm going to replace the above piece of code with a blank, so I write the following matching rule
<!–copyright[^!] *[^>]*>
All replacements are completed.
Common Regular Expressions
Delete empty line: Replace%[^t]++^p with empty string
Delete line trailing space: replace [^t]+$ to empty string]
Remove line start space: Replace%[^t]+ with empty string
Each line is set to start with a fixed 4 spaces: Replace%[^t]++^ ([~^t^p]^] = "^1″
Each paragraph is set to start with a fixed 4 spaces: replace%[^t]+ with ""
(If a line starts with a space, it is considered a beginning line)
Merge a segment into one line: replace [^t]++^p^ ([~^t^p]^] = ^1
(Note: This assumes that the text is a DOS carriage return line-cr/lf)
Remove Htmltag: Replace ^{<*>^}^{<*^p*>^} to empty string
Delete all of the HTML: replace <[]++a*[]++href[]++=*> empty string
Delete the first 2 columns of characters specified in the text: replace%?? is an empty string
Insert a 2-column white space character after the 4th column: replace%^ (???? ^) ^ (? ^) for "^1^2″
Find all the numbers: [0-9]+[.] ++[0-9]+
Find all the words: [a-z]+
Find all URLs: http://[a-z0-9^~ ' _./^-^? =&]+
Note: You need to check the use regular expression option when replacing

Using regular expressions in UltraEdit

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.