正则表达式备忘录-Regular Expressions Cheatsheet中文版
正则表达式备忘录
Regular Expressions Cheatsheet中文版
原文:https://www.maketecheasier.com/cheatsheet/regex/
|
测试文件a.txt |
|
0x1: If you work with text, you’ll appreciate how useful regular expressions are. 0x00001: Regular expressions are everywhere in Linux for searching through text right down to the character. 0x0000001: This Regular Expressions cheatsheet will be useful for people who simply need a little refresher from time to time. |
|
字符 |
描述 |
例子 |
|
|
. (点) |
任何单个字符,除了换行(\n) |
c.t 匹配 "cat", "cut" 或 "cot."。 '任意字符加im': [root@test: /tmp]# egrep '.im' a.txt who simply need a little refresher from time to time. |
|
|
* (星号) |
重复前一个表达式0或多次 |
12*3 匹配 "13", "123", "1223", "12223"。 与 . 合用代表任何字符。 m.*easier 匹配 "maketecheasier"。 'x加任意个0加1:' [root@test: /tmp]# egrep 'x0*1:' a.txt 0x1: 0x00001: 0x0000001: '任何包含f加任意字符加l' [root@test: /tmp]# egrep 'f.*l' a.txt how useful regular expressions are. will be useful for people |
|
|
+ (加号) |
重复前一个表达式1或多次 |
12+3 匹配 "123","1223","12223" 'x加至少一个0加1:' (比较上一个用*的) [root@test: /tmp]# egrep 'x0+1:' a.txt 0x00001: 0x0000001: |
|
|
? (问号) |
前一个字符可有可无 |
ma?ke 匹配 "make", "mke" '有n或无n加ee' [root@test: /tmp]# egrep 'n?ee' a.txt This Regular Expressions cheatsheet who simply need a little refresher |
|
|
^ (尖号) |
匹配字符串的开头 |
^he 匹配以he开头的 "hello", "hell", "help", "he is a boy" '以空格开头的行' [root@test: /tmp]# egrep '^ ' a.txt how useful regular expressions are. are everywhere in Linux for searching through text right down to the character. will be useful for people who simply need a little refresher from time to time. |
|
|
$ (美刀) |
匹配字符串的结尾 |
ed$ 匹配以ed结尾的 "acted", bed", "greed" '字母e结尾的行' [root@test: /tmp]# egrep 'e$' a.txt you’ll appreciate from time |
|
|
(...) (小括号) |
匹配字符组合 |
(ak) 匹配 "make", "take" '包含 it 的' [root@test: /tmp]# egrep '(it)' a.txt If you work with text, who simply need a little refresher |
|
|
{n} (大括号,n是大于0的整数) |
重复前一个字符n次,n>0 |
12{3}5 匹配 "12225" 'x加4个0加1' [root@test: /tmp]# egrep 'x0{4}1' a.txt 0x00001: |
|
|
[...] (中括号) |
匹配里面的任意一个字符 |
[abc] 匹配字符串"abc"中的"a","b" 或 "c" '所有包含v或b的' [root@test: /tmp]# egrep '[vb]' a.txt are everywhere in Linux will be useful |
|
|
[^...] |
匹配任意字符,除了里面定义的 |
a[^b]c 匹配 "aec", "acc", "adc", 但不匹配 "abc" 'f前面不能是空格或e' [root@test: /tmp]# egrep '[^ e]f' a.txt If you work with text, |
|
|
| (管道符) |
匹配管道符分隔的任一字符串 |
col(o|ou)r 匹配 "color", "colour" |
|
|
- (连字符) |
指定某个范围内的字符一般是[a-z],[A-Z],[1-9],[a-zA-Z1-9] |
a[a-z]c 匹配 "abc", "acc", "adc" |
|
|
\ (反斜线) |
转义符,将特殊符合转义为符号本身 |
a\*c 匹配 "a*c". |
|
|
\n, \r, \t |
代表 换行,回车,制表符 |
||
|
\b...\b |
匹配整个单词 |
\bTech\b 匹配 the word "Tech" in "Make Tech Easier". 找到单词time [root@test: /tmp]# egrep '\btime\b' a.txt from time to time. |
|
正则表达式备忘录-Regular Expressions Cheatsheet中文版的更多相关文章
- 正则表达式(Regular expressions)使用笔记
Regular expressions are a powerful language for matching text patterns. This page gives a basic intr ...
- [笔记] 精通正则表达式/Mastering Regular Expressions
/ 匹配<emphasis>这个tag标注的IP地址的RE:‘<emphasis>([0-9]+(\.[0-9]+){3})</emphasis>' / 锚定--a ...
- Regular Expressions all in one
Regular Expressions all in one Regular Expressions Cheatsheet https://developer.mozilla.org/en-US/do ...
- 自学Zabbix8.1 Regular expressions 正则表达式
点击返回:自学Zabbix之路 点击返回:自学Zabbix4.0之路 点击返回:自学zabbix集锦 自学Zabbix8.1 Regular expressions 正则表达式 1. 配置 点击Adm ...
- Python之Regular Expressions(正则表达式)
在编写处理字符串的程序或网页时,经常会有查找符合某些复杂规则的字符串的需要.正则表达式就是用于描述这些规则的工具.换句话说,正则表达式就是记录文本规则的代码. 很可能你使用过Windows/Dos下用 ...
- 转载:邮箱正则表达式Comparing E-mail Address Validating Regular Expressions
Comparing E-mail Address Validating Regular Expressions Updated: 2/3/2012 Summary This page compares ...
- Regular Expressions --正则表达式官方教程
http://docs.oracle.com/javase/tutorial/essential/regex/index.html This lesson explains how to use th ...
- Regular Expressions in Grep Command with 10 Examples --reference
Regular expressions are used to search and manipulate the text, based on the patterns. Most of the L ...
- Introducing Regular Expressions 学习笔记
Introducing Regular Expressions 读书笔记 工具: regexbuddy:http://download.csdn.net/tag/regexbuddy%E7%A0%B4 ...
随机推荐
- α测试,Beta测试
α测试(内测)是由一个用户在开发环境下进行的测试,也可以是公司内部的用户在模拟实际操作环境下进行的测试.α测试的目的是评价软件产品的FLURPS(即功能.局域化.可使用性.可靠性.性能和支持).尤其注 ...
- linux 检测服务器端口工具
#nmp# nmap 127.0.0.1 #netstat# netstat -anlp | grep 22 #telnet# 服务器端口即使处于监听状态,但是防火墙iptables屏蔽了该端口,是无 ...
- 洛谷 P1477 [NOI2008]假面舞会
题目链接 题目描述 一年一度的假面舞会又开始了,栋栋也兴致勃勃的参加了今年的舞会. 今年的面具都是主办方特别定制的.每个参加舞会的人都可以在入场时选择一 个自己喜欢的面具.每个面具都有一个编号,主办方 ...
- SGU - 275 线性基 初步
题意:求给出的数任意异或的最大值 目前对线性基的理解过于肤浅,有空总结一下 #include<iostream> #include<algorithm> #include< ...
- POJ - 2248 迭代加深
枚举ak的值 反向枚举使ak尽快到达最短链的n /*H E A D*/ int n,m,a[23333],dep; bool dfs(int x){ if(a[x-1]>n||a[x-1]< ...
- Maven-常规问题
1.编译(compile)Maven项目时,报错: -Dmaven.multiModuleProjectDirectory system property is not set. 处理方案:Windo ...
- Linux按键设备驱动一
① request_irq函数用于注册中断 int request_irq(unsigned int irq, void(*handler)(int, void*, struct pt_reg*), ...
- 《阿里如何实现秒级百万TPS?搜索离线大数据平台大数据平台架构解读》读后感
在使用淘宝时发现搜索框很神奇,它可以将将我们想要的商品全部查询出来,但是我们并感觉不到数据库查询的过程,速度很快.通过阅读这篇文章让我知道了搜索框背后包含着很多技术,对我以后的学习可能很有借鉴. 平时 ...
- vue组件传参
一.父子组件的定义 负值组件的定义有两种,我称为常规父子组件和特殊父子组件. 1.1.常规父子组件 将其他组件以import引入用自定义标签接收,在当前组件中component里注册该标签,页面上可以 ...
- 发送请求时params和data的区别
在使用axios时,注意到配置选项中包含params和data两者,以为他们是相同的,实则不然. 因为params是添加到url的请求字符串中的,用于get请求. 而data是添加到请求体(body) ...