Replacing ultraedit Regular Expressions

Source: Internet
Author: User
Tags ultraedit

I used ultraedit in, And I used regular expressions to search for it in. It was also in. I have never studied it in depth. I have been thinking about it several times. But now, the customer gave me a requirement that I can use regular expressions. after half an hour of exploration, I finally started to look at the door, but I was so happy to remember it.

 

Body:

The customer file is as follows:

....

} Li & quot; (a) | in general.-If T (the latter half is slightly the same as the former one)
} Ls I
} Li & quot; (I) | the percentage d
} Li & quot; (ii) | any increase in
} Li & quot; (B) | Determination
} PG 148
} Ls I
} Li & quot; (I) | the percentage d
} Li & apos; (ii) | the sum of
} Li & quot; (c) | aggregate contra
....

 

Requirements:

Change & quot; (serial number) | to (serial number) | & quot; serial number to 123 abc I II III ....

 

Ideas:

First, the regular expression provided for search is very easy to replace the serial number directly with * (all the following searches require the "Regular Expression" option to be checked in the search box of ultraedit). The search expression is as follows:

& Quot; (*) |

 

A search is successful.

 

The next step is to solve the problem: how to display the serial number in the replacement box before reading the information to help know that the replacement expression in UE is ^ X, and the range of X is 1-9, but the problem is that I have never known why what about ^ 1 in the expression? Obviously, the first and only annotation expression in my search expression is this *.

 

Step 1: directly write in the replacement expression

(^ 1) | & quot;

 

If the replacement is not successful as expected, replace the first & quot; (a) | with () | & quot; that is, ^ 1 has not obtained the value.

 

Step 2: Crazy ing

 

Step 3: Check the information and find an online example:

Merge a segment into one row: Replace [^ t] ++ ^ P ^ ([~ ^ T ^ p] ^) is ^ 1

A try is acceptable, but it is not used in it *? Where does wildcard like Ah ^ 1 come from? Surprising studies seem enlightened in the dark

Another sentence was found:

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.

 

Aha.The expression in a ^ (^) is a replacement region, that is, the wildcard corresponding to ^ 1 ^ 2!

Step 4: improve search methods

& Quot; ^ (*) ^) |

Replace

(^ 1) | & quot;

Execution discovery & quot; (a) | replaced with (c) | & quot;

Although it is not the result I want, the serial number has already appeared, that is, it is very close to the success. It is also logical to gradually find the final correct conclusion:

 

Conclusion:

  1. CTRL + R open the replacement window and check the regular expression Option
  2. Enter ^ (& quot; ^) ^ (*) ^ (| ^) (red) in the search box)
  3. Enter ^ 2 ^ 3 ^ 1 (red part) in the replacement box)
  4. Replace all with OK

Explanation: The Search expression is divided into three parts: ^ (& quot; ^) ^ (*) ^ (| ^). Can you see it?

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.