EditPlus common regular expressions

  Regular expressions (Regular Expression, the code is often abbreviated as regex, regexp or RE) is a concept in computer science. Regular expression to describe the use of a single string, the string line with a series of matching syntax rules. In many text editor, a regular expression is often used to retrieve, replace the text in line with those of a model. Many programming languages support regular expressions for string operations. In many text editor, a regular expression is often used to retrieve, replace the text in line with those of a model.

  A regular expression is a query string, which contains general characters and some special characters, special characters can extend the capabilities of the search string, regular expression search and replace strings role can not be ignored, it is a good increase productivity.

  Regular expressions are used string processing, form validation and so on, practical and efficient. Developer or operation and maintenance personnel are capable text editor to the number of editplus, this software supports regular expressions, use regular expressions to edit text often can help you do a lot of work. Here, I'll introduce several editplus common regular expressions to use to prepare for contingencies.

Common regular expression

[1] Application of a regular expression - replacing the specified content to the end of the line

  ① In the Replace dialog box, Find what, enter "abc. *"

  ② the same time check the "regular expression" check box, and then click "Replace All" button

  Wherein the symbols have the following meanings:

  . "" Matches any character =

  "*" = Match 0 or more times

  Note: in fact, regular expression substitution, here just some of the issues raised have been sorting out a simple regular expression itself from it, you can come out of thousands of exceptions.

[2] Regular Expressions - digital replacement

  We hope to

  asdadas123asdasdas456asdasdasd789asdasd

  Replace with:

  asdadas [123] asdasdas [456] asdasdasda [789] asdasda

  solve:

  [0-9][0-9][0-9] → [\0\1\2]

  If the number is an arbitrary string, "[0-9] * [0-9]"

[3] regular expressions application - delete the specified character each end of the trekking 

  such as

  12345 1265345

  2345

  We need to remove the end of each line of "345"

  solve:

  345 $ → empty

  If the first line, preceded by the "^"

[4] Application of a regular expression - replacing half-angle brackets with a plurality of rows

  Hundreds of pages have the following piece of code, I want them all removed, but find a lot of search & replace software is only on the "line" to operate.

  EditPlus open hundreds of pages of documents is quite smooth, so can do the job.

  solve

  Using regular expressions in Editplus, because "(", ")" is used as the default expression (or may be referred to as sub-expressions) logo, so it is necessary to use \ to escape.

[5] regular expressions application - delete blank lines

  ^ [\ T] * \ n → empty

  Note \ There are spaces before t. Component of the space character is a blank line. 

  Another method: [\ n] + → \ n

[6] regular expressions application - the middle contains the text replacement

  If you replace a line of text containing the intermediate, comprising e.g. yahoo, expression matching can be used as a single line

   ^.*yahoo.*

[7] regular expressions application - the middle does not contain text replacement

  If you replace the intermediate does not contain a line of text, for example, does not contain yahoo, expression matching can be used as a single line

  ^(?!.*yahoo).*

[8] to find and extract the url

  www.baidu.com">http://www.baidu.com

  solve:

  ()  → \1

  (http://.*) →\1

  Summary: EditPlus supports expression limited to the positive, the frequency of repetition defined does not support, such as: {3}, {3}, {3,6} ...

  Listed below EditPlus find or replace supported when metacharacters:

  Expression Description

  \ T tab.

  \ N new line.

  . Matches any character.

  | Character expression matching left and right, for example, "ab | bc". Match "ab" or "bc".

  [] Matches any single character in the list. For example, "[ab]" matches "a" or "b". "[0-9]" matches any number.

  Character [^] matches any character other than a single list. For example, "[^ ab]" Match "a" and "b" outside. "[^ 0-9]" matches any non-numeric characters.

  * Which match any characters are left (0 times, or more times). For example "be *" matches "b", "be" or "bee".

  + Leftmost character which is matched at least once (once or repeatedly). For example "be +" matching "be" or "bee" but does not match the "b".

  ? Character is matched to its left 0 or 1 times. For example "be?" Matches "b" or "be" but does not match "bee".

  ^ Their right of expression is matched at the beginning of the line. For example "^ A" matches only rows with "A" beginning.

  $ Left its expression to be matched at the end of a line, for example "e $" matches only "e" at the end of the line.

  () Effects of expression matching sequence, and serves as a packet marker expression.

  \ Escape character. If you want to use the "\" itself, you should use "\\".

Guess you like

Origin www.cnblogs.com/mq0036/p/12002889.html