Regular expression for Search and replace

Source: Internet
Author: User

The following examples apply in search and replace, and editplus have regular expressions, but they are somewhat different.

1.1 Basic operator

*

Repeat 0 or more times

+

Repeat one or more times

Repeat once

|

Or operator

Non-operator

^

Lines starting with the ^ post character

$

Lines ending with a $ preceding character

^^

File starting with ^ ^ after character

$$

File ending with a $$ character

[]

Range operator

()

Sub-string

+n

Specify the number of columns operator, often with () or [] with

1.2 Lookup of regular expressions

* Zeroor more Operator: matches expressions in () or [] 0 or more times. * can also be used alone, if used alone, will match all characters from start to finish in a line. You can also specify a character after * to match two or more expressions up to the maximum number of matches (which can be modified in the software).

Example: * (IS) occurs 0 or more times is, as is, Mississippi

*[is] appears 0 or more times I or S, such as Some, Expression,single

WINDOWS*[0-9] starts with Windows, followed by a 0-9-character string

Windows*[]95 begins with Windows, followed by any character followed by a string ending with 95

+One or more Operator: repeated occurrences of 1 or more operators.

Example: + (IS) match string Is,mississippi

W+e matches string wide,white,write, does not match we

? One occurrence Operator: Before or after the string appears once. It can also be placed between two strings and placed before (), indicating that an expression appears once in ().

Example:? (IS) match is

Win?95 match win 95,win-95,win/95

| or Operator: with the operator. Need to be used in conjunction with the () operator.

Example: (01/|02/) +[0-9] (/95|/98) match 01/15/98 and 02/12/98 the first three characters are 01/or 02/, followed by one to many digits of 0-9 digits, followed by/95 or/98

W*[a-z] (98|        NT) \?   Match Windows 98?,win NT? A string starting with W, followed by N (n>=1) bits of letters (must be A to Z), followed by 98 or NT characters, and finally ending with a. Note: To find an expression like, use the escape character \.

! Not Operator: non-operator. Can be used in conjunction with the () operator.

Example:? at! ((B|c) at) matches mat and sat instead of bat or cat. Note: Use of double brackets

*file! (beg*file) matches a file and this file instead of beginning of file

*98! (Windows 98) matches 1998 instead of Windows 98

*98! (+[a-z]98) matches 1998 instead of Windows 98

a?b?c! (AUB?C)! (A?BVC) Find axbyc,x not u,y not V

^ Beginningof line Operator: Take the following character as the beginning of the row, note that the line is not a word.

Example: ^the find lines that start with the,the,the

^ (the|          [A<]) Find lines that start with the or a or <

^* () bend\r\n* () Exit function match <space (s) (0 or more spaces) >Bend< Next row >exit function

$ endof line Operator: lines ending in $ after characters, similar to ^, can be used together with.

^^ Beginningof file Operator: Files that begin with the ^ ^ post character.

$$ Endof file Operator: Files ending with the $$ character.

[] Range Operator: You can refer to the example above, note that *[] matches the maximum number of strings that can be accommodated, including some line breaks, which can be found between multiple lines.

() subexpression Operator: You can refer to the example above for use.

+n Column specifier: You can refer to the example above for use.

Regular expression for Search and replace

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.