当前位置:网站首页>ICER skill 01 regular matching
ICER skill 01 regular matching
2022-06-23 04:57:00 【Eight four one one】
Catalog
1. Match instructions
| Symbol | effect |
|---|---|
| . | Matches any character |
| [abc] | Match any one of the characters in the formula brackets ( have access to - Indicates the character range , Such as [a-z 0-9] Match lowercase letters and Arabic numerals ) |
| [^abc] | Matches any character except those in square brackets |
| \d | Match Arabic numerals , Equate to [0-9] |
| \D | Match any character other than Arabic numerals , Equate to [^0-9] |
| \x | Match hexadecimal numbers |
| \X | Matches any character other than a hexadecimal digit |
| \w | Match word letters , Equate to [0-9 A-Z a-z] |
| \W | Match any character other than the letter of the word |
| \t | matching TAB character |
| \s | Matching blank character |
| \S | Match non white space characters |
2. Position symbol
| Symbol | The position of the representation |
|---|---|
| $ | Match the end of the line |
| ^ | Match the beginning of the line ( and [^abc] The symbols in have different functions ) |
| \ < | Match the beginning of the word |
| \ > | Match word endings |
3. Quantity symbol
| Symbol | Quantity represented |
|---|---|
| * | matching 0- Any one |
| \ + | matching 1- Any one |
| \ ? | matching 0-1 individual |
| \ {n,m} | matching n-m individual |
| \ {n} | matching n individual |
| \ {n,} | matching n- Any one |
| \ {,m} | matching 0-m individual |
4. Special symbols
| Symbol | effect |
|---|---|
| \ * | matching * character |
| \ . | matching . character |
| \ / | matching / character |
| \ \ | matching \ character |
| \ [ | matching [ character |
5. A few examples
① Put all the words help or Help All in capital letters HELP
:%s/[Hh]elp/HELP/g
- : Command instructions
- % All lines are valid
- s Search and replace
- [Hh] belt H or h
② Replace one or more spaces with a single space
:%s/ \ +//g
- \ + It means quantity
- // No space in is no space
③ Delete all blank lines ( There are no characters , Except for a carriage return )
- :g/^ $ /d: If there is no character between the beginning and end of the line, it will be deleted
- :g/[ \t]*$/d: Multiple spaces are deleted at the end of the line
④ Delete lines containing certain characters
:g/ERROR/d
- It is good to remember hhh
⑤ Delete all leading spaces in each line
:%s/^ *//g
- ^ *: Indicates that the character is known from the beginning of the line
⑥ Insert... At the beginning of each line in the file “->”
:%s/^/->/g
- Positioning line head , Insert a character
⑦ Delete with [a,b,c] Beginning line
:%s/^ [a|b|c].*$//g
- Delete abc Beginning line , instead of a The beginning or b Opening or c start
⑧ Use “\ (” and “\ )” The symbol encloses the normal expression , You can use it later \1 \2 And other variables \ ( and \ ) The content in
example :/ \ (a\ +\ )[^a]\ +\1
At the beginning and end a The same number of strings
- It is equivalent to saving and calling
matching aabbbaa
matching aaacccaaa
Mismatch abbbaa
⑧ Swap the order of all hyphenated entries in the list
ABC: XYZ
: %s/ (.* \ ):\ (.*\ )/\2:\ 1/g
- Save any character to \1
- Then match the colon :
- Save any characters to \2
- then 1 2 Swap for
边栏推荐
猜你喜欢

Can bus Basics

在Pycharm中使用append()方法对列表添加元素时提示“This list creation could be rewritten as a list literal“的解决方法

磁阻 磁饱和

Abnova actn4 purified rabbit polyclonal antibody instructions

Gson typeadapter adapter

独立站聊天机器人有哪些类型?如何快速创建属于自己的免费聊天机器人?只需3秒钟就能搞定!

Current relay hdl-a/1-110vdc-1

五年连续亏损42亿,蘑菇如何渡劫?

mysql json

gson TypeAdapter 适配器
随机推荐
20000 words + 20 pictures | details of nine data types and application scenarios of redis
Abnova abcb10 (human) recombinant protein specification
Abnova LiquidCell-负富集细胞分离和回收系统
Cocos learning diary 1 - node
Transformers中的动态学习率
积分商城的三种运营方向
反编译
Abnova PSMA磁珠解决方案
Shadertoy基础教学01、画圆(smoothstep()函数讲解)
Abnova fluorescent dye 510-m streptavidin scheme
What are the types of independent station chat robots? How to quickly create your own free chat robot? It only takes 3 seconds!
golang使用mongo-driver操作——增(基础)
Thinkphp6 template replacement
美团好文:从预编译的角度理解Swift与Objective-C及混编机制
notepad++ 查找替换之分组替换保留
mysql json
Laravel 8.4 routing problem. At the end is the cross reference table on the left side of the editor, which can be understood by Xiaobai
CVE-2019-14287(sudo提权)
静态双位置继电器 XJLS-84/440/DC220V
【论文阅读】Semi-Supervised Learning with Ladder Networks