UE Regular Expression

Source: Internet
Author: User
Tags expression engine ultraedit

UltraeditIs a powerful text editor that can edit text, Hex, and ASCII code. It can replace notepad, built-in English word check, C ++, and VB syntax highlighted, you can edit multiple files at the same time, and the speed of enabling a large file is not slow. The software provides HTML Tag color display, search replacement, and unlimited restoration functions.UltraeditSupports binary and hexadecimal editing, so it can also be used to modify the EXE
Or DLL file.

This article is intendedUltraeditIntroduction to experienced usersUltraeditThese features are often ignored by most users. the flexible use of these features will greatly improve work efficiency and achieve twice the result with half the effort. To use all the functions described in this tutorial, you mustUltraedit
Version 12.00 or later or uestudio 06.10 or later.

Column Mode

Column ModeUltraeditA powerful feature. The column mode allows you to select and edit data by column, while the general editor can only select data by row.

How to enter the column mode:

Use the shortcut key Alt + C, or use the menu
Column-> column mode, see

After entering the column mode, press the Shift key and the direction key on the keyboard to select multiple columns. The selected results are as follows: the cursor is changed to multiple columns.

When you type a character on the keyboardOne columnThe same character will appear, for example, press "/" twice on the keyboard. See the effect. This example is often used in programming. When You Need To comment a piece of code, you do not need to comment a line by line. Using the column mode can reduce a lot of repetitive work.

Insert/Fill column:

Taking the bibliography document as an example, the document lacks the information of the Publishing House, and the publishing houses of these books are "Electronic Industry ".Insert/Fill columns to easily complete this task.

First, select the columns to be filled in column mode and select the menu
Column>Insert/Fill the column, and a dialog box appears. EnterInsertClick "OK" after the text ".

After confirmingOne columnThe word "electronics industry" appears.

Here, you may ask, why don't you use the above method to select multiple columns and then directly input the word "electronics industry" on the keyboard? In fact, if you typed an English letter or character, there would be no problem. When you typed a Chinese character in the column mode, garbled characters will appear, so you can useInsert/Fill columns to solve this problem.

Have you ever felt this?UltraeditAnd you will findUltraeditCan do a lot of Excel jobs, or even jobs that cannot be completed in Excel.

InsertNumber:

Similarly, if the above bibliography is a column, we want to add a row number to the front of each row.

First, enter the column mode and selectOne columnThat is before the words "Title = ".One column, Select the menu column->InsertNumber. For example:

Click to enter the followingInsertNumber option box, we wantInsertThe starting number is 1, and the increment is also 1. to display the result neatly, we add zero at the beginning of the column.

After setting by, click "OK". For the effect, see,InsertThe row number is finished.

As mentioned aboveUltraeditTo do a lot of Excel work, let's take a look at how to sum by column.

Column/selection statistics:

In the above bibliography, there is a price column marking the price of each book. If you want to know the total price of these books, It is very simple:

First select these prices in column mode, and then click the menu
Column-> column/selection statistics

In the displayed dialog box, click statistics to view the statistics. In this dialog box, "ignore the characters in the Data" is filled with "," which ensures that the data you want to collect can also be normally counted when the data is separated by kilobytes, such as the number "24,501 ″.

You may have a question: the file we processed above is in a neat format, but the initial data we often get is not neat. What should we do when we want to calculate the total price of these books? The following section describes the function of converting to a fixed column to solve this problem.

Convert to a fixed column:

The following dialog box is displayed when you convert a menu column to a fixed column. delimiter characters are set based on the file conditions. In this example, the Delimiter is tab, and "^ t" is entered ", keep the default value for other settings, and click "scan". The result after the scan is displayed in the bottom box. In this example, "10, 27, 3, 8" indicates the first field (serial number) 10 columns, 27 columns for the second field (title), and so on.

Generally, we do not need to change the scan results, and direct point conversion will be able to achieve the effect. This will be convenient for both statistics and sorting.

Sort (SORT)

Sorting isUltraeditIt is a very practical feature that may make it easier to use Excel, but do not forget that excel only supports 65535 rows of data, whileUltraeditProcessing millions of rows of data is not a problem, and the function is no inferior to excel.

The following uses a simple document as an example to describe how to sort the table. For details, see: This is a commodity table.One columnYes. We want to sort files by price.

First, choose menu File> sort> advanced sort/option. For more information, see

The following sorting option dialog box is displayed:

Sort order: Select ascending or descending.

Delete duplicate items: Delete the same row in the file. Only one row is retained. (Think about how to remove repeated items in Excel)

Numerical sorting: When the column to be sorted is a number and you need to select this option when you are concerned about its actual size, the following example will illustrate this problem.

Sort column: You can set a total of four columns, which are specified by the START column and end column.

Suppose we want to sort this file in ascending order of price and select ascending order in this dialog box. Because we are concerned about the actual size of the value, we select the numbers to sort, the price field is determined by the ruler from column 65 to column 71. Click "sort" after setting. The result is as follows. (If you cannot see the ruler, you may use the menu
View-> display the ruler)

If you do not select the number sorting option, the result shown is displayed. It can be seen that it is sorted by the ASCII code, rather than the real size of the value.

Regular Expression search and replacement

First, let's explain what is a regular expression: I believe you have used wildcards for file search in Windows or DoS, that is, * and ?. If you want to find all the Word documents under a directory, you will naturally search for "*. Doc ". Here, "*" is interpreted as any string. Like wildcards, regular expressions are also a tool for text matching. They can describe your needs more accurately than wildcards. Of course, the cost is more complex. For example, to search for files with Doc extension, the regular expression is ". * \. Doc ". Although it is much more complicated, regular expressions can meet almost all your search needs. For example, you can write a regular expression to find all numbers starting with 0 followed by 2-3 numbers, and then a font size "-", it is a string of 7 or 8 digits (such as 010-12345678 or 0376-7654321 ).

InUltraeditRegular Expressions are well supported. Currently, three types of regular expressions are supported,UltraeditRegular Expressions, Unix regular expressions, and Perl-Compatible Regular Expressions. This article introduces Perl-Compatible Regular Expressions. This is a widely used regular expression, which is supported by most programming languages.

To use Perl Compatible Regular Expressions, you mustUltraedit. Click menu
Advanced> Configuration. In the displayed dialog box, select Regular Expression Engine on the left side and Perl Compatible Regular Expression on the right side ".

Regular Expression Syntax:

The focus of this article is not on the regular expression syntax.

Metacharacters:

Metacharacters Description
. Match any character except linefeed
\ W Match letters, numbers, underscores, or Chinese Characters
\ S Match any blank space character ()
\ D Matching number
\ B Start or end of a matching word
\ W Match any character that is not a letter, number, underline, or Chinese Character
\ S Match any character that is not a blank character
\ D Match any non-numeric characters
\ B Match is not the start or end of a word
^ Match the beginning of a row
$ Match the end of a row

Character escape

If you want to find the metacharacters themselves, use "\" to convert them. For example, "." represents any character other than line breaks. If you want to search for ".", you need to use "\.".

Repeated

Syntax Description
* Repeated zero or more times
+ Repeat once or more times
? Zero or one repetition
{N} Repeated n times
{N ,} Repeat N or more times
{N, m} Repeat n to m times

Character Set

To match any of the five characters of aeiou, it can be expressed as [aeiou]. Another example is [0-9], which represents any number between 0 and 9. Its meaning and \ D in the element are actually the same.

Anti-Italian

If you want to match non-a, [^ A], which is expressed as [^ aeiou] except five letters of aeiou,

Greedy and stop greedy

String DVEADeBCADEFBOipi, regular expression A. * B, which indicates that the expression matches any number of characters starting from a and ending with B. The matching result of this expression isADeBCADEFBInsteadADeBWe call this greedy match because it matches as many characters as possible. To prevent this greedy match, use "?", Write the above expression as .*? B, the matching result isADeB.

UltraeditRegular Expression search in

We use an HTML example to search for a <ul> HTML Tag. First, you must specify the features of the string to be searched: it ends with <ul> and contains any characters (including line breaks) in the middle ), the expression can be written as <ul [\ s] *? Ul>. Here [\ s] indicates white space and non-white space (that is, all characters), followed by * indicates any number ,? Indicates non-greedy search.

After confirming the expression, press Ctrl + F on the keyboard to enter the expression in the pop-up Search dialog box, select "Regular Expression", and click "find next" to see the search results.

UltraeditReplace the Regular Expression in

InUltraeditRegular Expressions can be used not only for queries but also for replacement. A complex replacement is described here. Take the file as an example. There are many dates in this article, in this format DD/MM/YYYY. We want to replace it with the format of yyyy-mm-dd.

Since it is a replacement, you must first check the target string and use \ D to represent the data. Each month and day are composed of one or two digits. The regular expression is represented as \ D {1, 2 }, the year is represented by four numbers \ D {4}, plus the separator/in the middle /, the entire date string can be represented as \ D {1, 2}/\ D {1, 2}/\ D {4 }. The goal of our replacement is to put the last year in the first place, so we also need this search to return the values of each part. In Perl regular expressions, we can use () to return the values in the search string, $1 is used to represent the value in the first bracket. Therefore, we add three parentheses to convert them to (\ D {})/(\ D }) /(\ D {4}), then the $1 Table is on the day, $2 indicates the month, and $3 indicates the year. It is easy to achieve our goal here.

Press Ctrl + R on the keyboard to bring up the replacement dialog box. Find the content as (\ D {1, 2})/(\ D {1, 2})/(\ D {4 }), replace the regular expression with $3-$2-$1 ".

Fill in "replace all". For the effect after replacement, see.

Common Regular Expressions

Space at the beginning of the line: ^ \ s +

Space at the end of the line: \ s + $

IP Address: [0-9] {1, 3} \. [0-9] {1, 3} \. [0-9] {1, 3} \. [0-9] {1, 3}

Positive Integer: ^ [1-9] \ D * $

Negative integer: ^-[1-9] \ D * $

Remote File editing

For those who are new to Linux, editing files on Linux is a very painful use. The vi editor on Linux is not likeUltraeditSo easy to use, in the absenceUltraeditYou may have to download and edit the file before uploading it.UltraeditIn this case, you do not need to worry about it. He directly opens the files on the remote machine and automatically uploads the files to the remote server after saving them.

It is easy to use this function. Click the menu File> FTP/telnet> to open it from ftp, as shown in.

If you have configured an FTP account, click "Browse site" to view the files on the remote machine. Select the file to be edited and click open.Ultraedit. See.

If you are using this function for the first time, click the "Account" button in. The account manager shown in the dialog box is displayed, and you can add an account through simple settings.

Note:: It is not recommended to use this function to edit system core files. If a network failure occurs during storage, the files may be lost.

Freeze window

ImplementationUltraeditDoes not freeze the window.UltraeditIt can be used to freeze Windows Similar to excel. In Excel, we often use this function to fix the table header so that the table header remains unchanged when the table is scroll up or down.

UltraeditYou can actually fix the left column, and only the right column is moved when the horizontal bar is rolled. For example, a bibliography fileOne columnIs the name of the book, and the price isOne columnAt the end, there is a lot of content in the middle. When the price class is rolled to the middle of the view, the title cannot be seen. So we wantOne columnFixed. When scrolling the horizontal bar, you must first set a column label and click the menu.
View-> set column tags, as shown in.

In the displayed set column mark dialog box, the first row is checked and the value is the end column of the title. For example.

After setting it, click "OK". A vertical line is added to the 41 columns, and then click the menu.
View-> mark 1 on the left without scrolling, so that the content before the 41 columns will not change when the horizontal bar is rolling. You can roll the content behind it to the front. See.

Highlight the syntax

The syntax is highlighted as follows:UltraeditIt can color Keywords of various syntaxes like IDE development environments in various languages.UltraeditA file called wordfile is used to define the coloring rules for various languages. Add a syntax rule.Ultraedit.

By defaultUltraeditOracle SQL syntax coloring is not supported. The following example shows how to makeUltraeditRecognizes Oracle SQL scripts and colors keywords.

First open the wordfile definition file, click the menu
Advanced-> Configuration, find "syntax highlighted" on the left, and click "open" on the right to open the wordfile.

Download the Oracle syntax definition file from the official website. The official website provides hundreds of syntax definition files, which can be downloaded as needed at http: // www.Ultraedit. Com/downloads/extras.html # wordfiles.

Stick the downloaded file to the end of the wordfile and save it. For example

However, you should note that there is a/L followed by a number at the beginning of the next content. This data needs to be changed according to your own situation. This is a number. It cannot be the same as the number already in wordfile and cannot exceed 20. You can use the following method to determine the number, and click the "view mode" button on the toolbar,

Then, in the pop-up menu, the languages 15 to 20 in the red box are all numbers that are currently not used by the system, so here we can change this number to 15.

After saving, when we open the Oracle SQL script again, the keywords in the syntax will be automatically colored.

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.