notepad++ Regular Expression syntax

Source: Internet
Author: User
Tags mongodb postgresql redis

notepad++ Regular Expression Syntax


\ escape Character Furu: to use "\" itself, you should use the "\"



\ t Tab TAB Note: Both the extension and the regular expression support



\ r Carriage return CR Note: Extended support, regular expression does not support



\ n newline character LF Note: Extended support, regular expressions do not support



. Match any character



^ The expression to its right is matched at the top of the row. For example: ^a matches a line beginning with "A"



The expression to the left of the line is matched at the end of the row. For example: e$ matches lines ending with "e"



| Or an operator that matches the string to the left and right of the expression. such as: AB|BC matching "ab" or "BC"



[] matches any single character in the list. For example: [AB] matches "a" or "B"; [0-9] matches any single number



[^] matches any single character except the list. For example: [^ab] matches a single character other than "a" and "B"; [^0-9] matches any single non-numeric character



* The character on its left side is matched to any number of times (0 or more times). such as: be* match "B", "Be" or "bee"



+ the character on its left side is matched at least once (1 or more times). such as: be+ match "be" or "bee", but do not match "B"



? The character on the left side is matched 0 or 1 times. such as: be? matches "B" or "be", but does not match "bee"



() The order that affects the expression matching (such as C + + parentheses affects the order of expression operations), and is used as the grouping marker for the expression (marker starting from 1) Note: See the example below



\d matches a numeric character. Equivalent to: [0-9]



\d \d The reverse, matching a non-numeric character. Equivalent to: [^0-9]



\s matches any single whitespace character: including spaces, tabs, and so on (note: Do not include change and line breaks). Equivalent to: [\ t]



\s \s Any single character that is reversed.



\w matches any single character that includes an underscore. Equivalent to: [a-za-z0-9_]



\w \w Any single character that is reversed. Equivalent to: [^a-za-z0-9_]



Example 1



123abcfg
Abc
Abcd



Replace with:



123hello
Hello
Hello



Method--Find string: abc.*$ replacement string: Hello



Example 2



123abcfg
Abc
Abcd



Replace with:



123@abcfg@
@abc @
@abcd @



Method--Find string: (abc.*) $ replacement string: @\1@



Example 3



STR[1]ABC[991]
STR[2]ABC[992]
STR[11]ABC[993]
STR[222]ABC[996]



Replace into



GOD[991]
GOD[992]
GOD[993]
GOD[996]



Method 1--Find string: str\[[0-9]+\]abc\[([0-9]+) \] Replace string: god[\1]



Method 2--Find string: str\[([0-9]+) \]abc\[([0-9]+) \] Replace string: god[\2]



Example 4 Delete all blank lines



Step1:a. Select Regular Expression B. Find string: ^[\t]*$ Replacement string: Empty



Step2:a.  Select Extension (\n,\r,\t,\0,\x ...) B. Find string: \r\n\r\n Replacement string: \ r \ n Note: Multiple Click Replace until no replaceable string


Alibaba Cloud Hot Products

Elastic Compute Service (ECS) Dedicated Host (DDH) ApsaraDB RDS for MySQL (RDS) ApsaraDB for PolarDB(PolarDB) AnalyticDB for PostgreSQL (ADB for PG)
AnalyticDB for MySQL(ADB for MySQL) Data Transmission Service (DTS) Server Load Balancer (SLB) Global Accelerator (GA) Cloud Enterprise Network (CEN)
Object Storage Service (OSS) Content Delivery Network (CDN) Short Message Service (SMS) Container Service for Kubernetes (ACK) Data Lake Analytics (DLA)

ApsaraDB for Redis (Redis)

ApsaraDB for MongoDB (MongoDB) NAT Gateway VPN Gateway Cloud Firewall
Anti-DDoS Web Application Firewall (WAF) Log Service DataWorks MaxCompute
Elastic MapReduce (EMR) Elasticsearch

Alibaba Cloud Free Trail

Related Article

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.