Today, my friend wants to convert the constant definition (# define MAX 0 xFFFF) written in C to the java constant definition (public static final int MAX = 0 xFFFF;) because of the large volume, I am too lazy to write java code for a file, so I decided to replace it with the regular expression function of UltraEdit. My friend needs to easily replace # define with public static final int and then set 0x ^ (???? ^) Replace it with = 0x ^ 1; in this case, because the regular expression of UltraEdit is quite different from the regular expression of Orthodox, I will refer to the UltraEdit Regular Expression document. UltraEdit 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. |
Delete blank rows: replace % [^ t] ^ p with the space at the end of the empty string to delete rows: Replace [^ t] $ with the space at the beginning of the empty string to delete rows: replace % [^ t] with an empty string. Each line is set to a fixed four-space Prefix: replace % [^ t] ^ ([~ ^ T ^ p] ^) is set to "^ 1". Each segment starts with a fixed four-character space: replace % [^ t] ""
(If a row starts with a space, it is regarded as the starting line of the segment.) Merge the segment into one row: Replace [^ t] ^ p ^ ([~ ^ T ^ p] ^) is ^ 1
(Note: here we assume that the text is a line break in DOS mode-CR/LF) Remove the html tag: replace ^ {<*> ^} ^ {<* ^ p *> ^} with an empty string to delete all the values in HTML. <A>: replace <[] a * [] href [] = *> with % ?? Insert two blank characters for an empty string after the first column: replace % ^ (???? ^) ^ (? ^) For "^ 1 ^ 2" to find all the numbers: [0-9] [.] [0-9] Find all words: [a-z] Find all urls: http: // [a-z0-9 ^ ~ '_./^-^? = &] Note: You must check the option of using regular expressions when replacing the regular expression.