当前位置:网站首页>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
边栏推荐
- Magic POI error in reading excel template file
- 使用Fiddler模拟弱网测试(2G/3G)
- xpath
- Analysis of stone merging
- Gbase 8A OLAP analysis function cume_ Example of dist
- JVM memory structure when creating objects
- 百万年薪独家专访,开发人员不修复bug怎么办?
- Slow bear market, bit Store provides stable stacking products to help you cross the bull and bear
- excel读取文件内容方法
- Xiao Wang's interview training task
猜你喜欢
![[leetcode] dynamic programming solution split integer i[silver fox]](/img/18/8dc8159037ec1262444db8899cde0c.png)
[leetcode] dynamic programming solution split integer i[silver fox]

Go从入门到实战——package(笔记)

Figure countdownlatch and cyclicbarrier based on AQS queue

vmware虚拟机PE启动

Go from introduction to actual combat - package (notes)

∫(0→1) ln(1+x) / (x ² + 1) dx

Interval DP of Changyou dynamic programming

What is the core competitiveness of front-line R & D personnel aged 35~40 in this position?

Go从入门到实战——接口(笔记)

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
随机推荐
Go from starting to Real - Interface (note)
Go从入门到实战——Panic和recover(笔记)
Go从入门到实战——package(笔记)
管理系统-ITclub(下)
Go 访问GBase 8a 数据库的一个方法
JVM memory structure when creating objects
Quick excel export according to customized excel Title Template
Open source technology exchange - Introduction to Chengying, a one-stop fully automated operation and maintenance manager
Express e stack - small items in array
[LeetCode]572. 另一棵树的子树
The difference between scrum and Kanban
Experience sharing of meituan 20K Software Test Engineers
Software defect management - a must for testers
Simulink method for exporting FMU model files
Xiao Wang's interview training task
Gbase 8A OLAP analysis function cume_ Example of dist
GBase 8a数据库用户密码安全相关参数汇总
Go从入门到实战——协程机制(笔记)
Little known MySQL import data
哈希表-数组之和