In addition to using the IDE to edit code, programmers often use lightweight editors, such as ultraedit and notepad ++. Among these editors, we often use the "Search" function ", "Replace ". These software provides a variety of search replacement functions, and even provides regular expressions to assist in search replacement. The following table lists the regular expression syntax of UE.
Regular Expression (ultraedit syntax ):
Symbol |
Function |
% |
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 end of the line 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. |
++ |
Matches the previous character/expression zero or multiple times. Duplicate line breaks are not matched. |
^ B |
Match a paging character. |
^ P |
Match a line break (CR/LF) (Section) (DOS file) |
^ R |
Match a line break (CR only) (Section) (MAC file) |
^ N |
Match A linefeed (lf only) (Section) (UNIX file) |
^ T |
Match 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 to the expression and use them 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. |
For example:
M? N matches "man", "men", and "min", but does not match "moon ".
T * t matches "Tea t" in "test", "tonight", and "tea time", but does not match "tea"
Time (there is a line break between "tea" and "time ).
Te + st matches "test", "teest", and "teeeest", but does not match "TST ".
[Aeiou] matches each vowel in lower case
[,.?] Match the text ",", ".", or "?".
[0-9a-z] matches any number or lowercase letter
[~ 0-9] match any character except a number (~ Does not match the subsequent content)
Example:
1. Search for rows starting with a specified string
% Yourstring
2. Delete the row ending with the specified string
Yourstring $
3. Delete space rows
Search: ^ p $
Replace with: NULL
4. Delete rows containing specific strings
Search: % * your string * ^ P
Replace with: NULL
In addition, if the regular expression is not selected in search/replace, the following special characters in the replace object are also valid:
Symbol |
Function |
^ |
Match the character "^" |
^ S |
Indicates the selected (highlighted) text in the activity file window. |
^ C |
The content of the clipboard table. |
^ B |
Match a paging character. |
^ P |
Match a line break (CR/LF) (Section) (DOS file) |
^ R |
Match a line break (CR only) (Section) (MAC file) |
^ N |
Match A linefeed (lf only) (Section) (UNIX file) |
^ T |
Match a tab |
Zookeeper
Advanced Search function of ultraedit