当前位置:网站首页>regular expression
regular expression
2022-06-27 21:59:00 【JAPAN_ is_ shit】
Preface
Regular expression Basics
Regular expressions
One . Character set
Some character sets are predefined in regular expressions , The character set can express some matching rules represented by meta characters and ordinary characters in a concise way .
The following is the character set , In the character set unicode Characters within , So in both Chinese and English [0-9] Representation number ,[A-Za-z] It means that the letters are accurate .
. Matching elimination \n\r Any character of
\d Match a number , Approximately equivalent [0-9], Wider scope
\D Match a non number
\w Match an alphanumeric underlined word character , Approximately equivalent [A-Za-z0-9_], Wider scope
\W Match a non word character
\s Match an invisible character
\S Match a visible character
\b Match the boundaries of words , Matching position
\B Match the non boundary of the word
Two . qualifiers
* Match the previous expression any number of times
+ Match the previous expression 1 Times or times
? Match the previous expression 0 Once or once
() Define the expression between as “ Group ”(group), They can use \1 To \9 To quote .
(q)(w)\1\2 Will match to the qwqw
[] Match any of the characters it contains
{
} The matching times of the previous expression
| Logic or operation
- A hyphen , Scope of representation
^ Start matching from the string header
$ Match from the end of the string
3、 ... and . Common expression
1. Matching position
(pattern) Get matching pattern value
The following four are non fetch matches , Mainly used to locate
(?=pattern) Positive positive matching 123(?=\.jpg) To match .jpg Previous 123
(?<=pattern) Reverse positive match (?<=123)\.jpg To match 123 hinder .jpg
(?!pattern) Positive negative matching 123(?!\.jpg) Finger mismatch .jpg Previous 123
(?<!pattern) Reverse negative match (?<!123)\.jpg Finger mismatch 123 hinder .jpg
2. Group references
([A-Za-z])(\1) (\1) Get the value of the first group , Match two consecutive identical letters
([A-Za-z])([A-Za-z])(\1)(\2) ABAB Type character
([\u4e00-\u9fa5])(\1)([\u4e00-\u9fa5])(\3) AABB Chinese Idioms
3. Non greedy model
+ * {
} The default is greedy mode , add ? It will be transformed into a non greedy mode
边栏推荐
- 我想我要开始写我自己的博客了。
- TreeSet details
- 快速excel导出
- Software defect management - a must for testers
- Matlab finds the position of a row or column in the matrix
- Set code exercise
- qt base64加解密
- 语言弱点列表--CWE,一个值得学习的网站
- Process control task
- C language programming detailed version (learning note 1) I can't understand it after reading, and I can't help it.
猜你喜欢

win11桌面出現“了解此圖片”如何删除

Go从入门到实战——依赖管理(笔记)

List of language weaknesses --cwe, a website worth learning

Simulink method for exporting FMU model files

Go从入门到实战——错误机制(笔记)

Go from entry to practice -- CSP concurrency mechanism (note)

I think I should start writing my own blog.

Figure countdownlatch and cyclicbarrier based on AQS queue

Null pointer exception

The create database of gbase 8A takes a long time to query and is suspected to be stuck
随机推荐
Gbase 8A OLAP analysis function cume_ Example of dist
Go from introduction to practice - polymorphism (note)
List of language weaknesses --cwe, a website worth learning
At 19:00 on Tuesday evening, the 8th live broadcast of battle code Pioneer - how to participate in openharmony's open source contribution in multiple directions
Method of reading file contents by Excel
[leetcode] dynamic programming solution split integer i[silver fox]
QT large file generation MD5 check code
Little known MySQL import data
正则表达式
Go from introduction to practice -- coordination mechanism (note)
win11桌面出現“了解此圖片”如何删除
Array assignment
Figure countdownlatch and cyclicbarrier based on AQS queue
[LeetCode]100. 相同的树
Simulink导出FMU模型文件方法
有时间看看ognl表达式
Xiao Wang's interview training task
excel读取文件内容方法
Summary of gbase 8A database user password security related parameters
Go从入门到实战——共享内存并发机制(笔记)