Ultraedit Regular Expression

Source: Internet
Author: User
Tags expression engine ultraedit

Ultraedit (hereinafter referred to as UE) is a text editing software that I often use. Its powerful functions make me fall in love with it. If you don't need to use it every day, you will feel uncomfortable. Starting from 9. From 0 to 12. 10a (I only use this version). ue is a must-have feature after the system is reinstalled. In addition to the common text editing function, ue has a very good ability to edit hexadecimal files. I don't know much about the charm of UE in hexadecimal files due to work reasons, we hope to share the xdjm with others. Not to mention, below is the regular expression syntax of several generations in ue.

First, you need to press "advanced"-"configuration"-"Search"-"Regular Expression Engine" in ue to select which regular expression to use.

 

If you select "ultraedit-style regular expression", you will use the syntax rules of "ultraedit-style regular expression" in future search and replacement functions.

In the current version, "Perl-Compatible Regular Expressions" are also added, which will be mentioned in future articles.

Ultraedit-style regular expression syntax

1.%

Function Description: match the starting position of a row. This symbol indicates the starting position of the searched character on each line, excluding the ending character of the previous line on each line.

2. $

Function Description: matches the end position of a row. This symbol indicates the position of the searched character at the end of each line. This $ is the opposite of the line header mentioned above. It is the end of the line ".

3 ,?

Function Description: matches each character except the line break.

4 ,*

Function Description: matches any number of characters except line breaks.

5. +

Function Description: Match one or more mentioned characters or expressions, at least once. Duplicate line breaks are not matched ".

6. ++

Function Description: matches zero or many times the mentioned characters or expressions, and does not match repeated "line breaks ".

7. ^ B

Function Description: match a paging character.

8. ^ P

Function Description: Match line breaks in DOS files.

9. ^ r

Function Description: match the line break in the Mac file.

10, ^ n

Function Description: Match line breaks in UNIX files.

11. ^ t

Function Description: match a Tab character.

12. []

Function Description: matches any single character in square brackets and can be expressed in a range.

13. ^ {A ^} ^ {B ^}

Function Description: matches expression a or expression B.

14. ^

Function Description: The subsequent regular expression is invalid.

Note: You can also specify the beginning of a row.

15. ^ (... ^)

Function Description: matches 1st to 9th specified expressions and can be used to change positions.

For example, "Hello World" satisfies the expression "^ (H * o ^) ^ (w * d ^ )", the expression "^ 2 ^ 1" can replace "Hello World" with "World Hello ".

Let's take a look at some simple examples below:

M? N matches "man", "men", and "min", but does not match "moon ".

T * t matches "test", "tonight", and "tea time", but cannot match "tea time" (The linefeed is between "tea" and "time ).

Te + st matches "test", "teest", "teeeest", and so on, but cannot match "TST ".

[Aeiou] matches any letter of aeiou

[,.?] Match "," and "." And "?" Any

[0-9a-z] matches lowercase letters from A to Z of any 1-9 digits.

[~ 0-9] match any character except a number (~ The symbol indicates "not ")

Here we only introduce the syntax of "traditional regular expressions" in ue, which is quite simple, but they can meet the requirements of batch text processing. It is even more fun to use your computer.

TIPS: Regular Expressions are regular expressions in English. The essence of regular expressions is "unified configuration ". A wide range of "Variants" are enough to prove its position in text editing software. In the current ultraedit version, in addition to the traditional regular expressions and Unix-style regular expressions, It also adds Perl-Compatible Regular Expression syntax, which can be said to make ultraedit more perfect.

 

Yesterday, the little thumb was sore because Ctrl + C and CTRL + V operations were frequent. Using the Regular Expression of ultraedit today reduces the trouble.

A text document that contains many keywords. Each keyword occupies one line. Now you need to view the baidu search results of these words.

Use ultraedit to open a text document. Press Ctrl + R to bring up the "replace" window. Enter "% ^ (* ^) $" in "search content" (excluding double quotation marks ), replace with input "<a href =" http://www.baidu.com/s? WD = ^ 1 "target = _ blank> ^ 1 </a> ^ P", save it, change the suffix of the text file to "html", and open it. OK. Click here to bring up the baidu search result.

 

The Regular Expression Function of ultraedit is very useful. I will post two articles:

Use a regular expression in ultraedit

Delete empty rows: replace % [^ t] ++ ^ P with empty strings.

Remove trailing space: Replace [^ t] + $ with an empty string

Space at the beginning of the row to be deleted: % [^ t] + is replaced with an empty string

Each line starts with four fixed spaces: replace % [^ t] ++ ^ ([~ ^ T ^ p] ^) is "^ 1"

Each segment starts with a fixed 4-digit space: replace % [^ t] + ""

(If a line starts with a space, it is regarded as the starting line of a segment)

Merge a 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 HTML Tag: replace ^ {<*> ^} ^ {<* ^ p *> ^} with an empty string.

Delete all <A>: replace <[] ++ A * [] ++ href [] ++ = *> with an empty string.

Delete the first two columns of characters specified in the text: replace % ?? Empty string

Insert 2 blank characters after the first column: replace % ^ (???? ^) ^ (? ^) Is "^ 1 ^ 2"

Search for all numbers: [0-9] + [.] ++ [0-9] +

Find all words: [A-Z] +

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

 

Simple and practical Regular Expression manual for ultraedit

Ultraedit allows you to use regular expressions in many search and replacement functions listed under the search menu. Regular Expressions allow more complex search and replacement functions to become simple operations. (The Chinese version is displayed as a regular expression ")

There are two available syntax sets. The first table below shows the original ultraedit syntax used in earlier versions of ultraedit. The second table provides an optional Regular Expression of the "Unix" type. This can be enabled from the Configuration unit.

Symbol function

% Match the start of a row-show that the search string must start at the row, but does not include any line terminator in the selected result string.

$ Match the end of a row-the search string must be at the end of the row, but the selected result string does not contain any line terminator.

? Match any single character except line breaks

* Except for line breaks that match any number of characters and numbers

+ Match one or more of the previous characters, but at least one

++ The first character matches zero or more characters, but at least one character must appear.

^ B matches a page

^ P matches a linefeed (CR/LF) (segment) (DOS file)

^ R matches a line break (CR only) (segment) (MAC file)

^ N matches a linefeed (lf only) (segment) (UNIX file)

^ T matches a Tab character

[] Match any single character or range in square brackets

^ {A ^} ^ {B ^} matching expression A or B

^ Reload the regular expression character

^ (^) Includes or is marked as the expression used to replace the command.

A regular expression can have a maximum of nine annotation expressions, depending on the needs of regular expressions.

The corresponding replacement expression is ^ X, and the replacement range is 1-9. For example:

If ^ (H * o ^) ^ (F * s ^) matches "Hello folks ",

^ 2 ^ 1 wocould replace it with "Folks hello ".

(Hello folks will be replaced with folks hello .)

Note: ^ is the actual character ^ is not the CTL + key value.

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.