Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Notepad regular expression

2025-04-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

One-two! -~] Chinese

Add something to the back

Characters. * characters after deletion

\ escape characters such as: to use "\" itself, you should use "\"

\ t TAB Tab Note: both extensions and regular expressions are supported

\ r carriage return CR Note: extension is supported, regular expressions are not supported

\ nNewline character LF Note: extension is supported, but regular expressions are not supported

. Match any character

The expression to the right of ^ is matched at the beginning of the line. For example, ^ A matches lines that start with "A"

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

| or operator that matches the string to the left and right of the expression. For example: ab | bc matches "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 outside the list. For example, [^ ab] matches a single character other than "a" and "b"; [^ 0-9] matches any single non-numeric character

The character to its left is matched any number of times (0 or more times). For example, be* matches "b", "be" or "bee"

The character to its left is matched at least once (1 or more times). For example, be+ matches "be" or "bee", but not "b"

? The character on its left is matched 0 or 1 times. Such as: be? Matches "b" or "be" but not "bee"

() affects the order in which expressions are matched (parentheses like C++ affect the order in which expressions are evaluated) and are used as grouping markers for expressions (tags start at 1) Note: see the example below

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

\ D\ d is inverted to match a non-numeric character. Equivalent to: [^ 0-9]

\ s matches any single white space character: including spaces, tabs, etc. (note: newline and newline characters are not included). Equivalent to: [\ t]

Any single character inverted by\ S\ s.

\ w matches any single character including an underscore. Equivalent to: [A-Za-z0-9]

Any single character inverted by\ W\ w. Equivalent to: [^ A-Za-z0-9 _]

Example 1

123abcfg

Abc

Abcd

To be replaced by:

123hello

Hello

Hello

Method-find string: abc.*$ replacement string: hello

Example 2

123abcfg

Abc

Abcd

To be replaced by:

123@abcfg@@abc@br/ > @ abc@

Method-find string: (abc.*) $replace string: @\ 1@

Example 3

Str [1] abc [991]

Str [2] abc [992]

Str [11] abc [993]

Str [222] abc [996]

Replace with

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 the regular expression b. Find string: ^ [\ t] * $replacement string: empty

Step2:a. Select extension (\ n,\ r,\ t,\ 0,\ x.) b. Find string:\ r\ n\ r\ nreplace string:\ r\ nNote: click replace multiple times until there is no replaceable string

Li Jun tel:15135361516 Qq:344728662

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report