网站首页 > 技术文章 正文
首先是特殊的Metacharacter:
. * + ? ^ $ \ [
注意的一点,emacs的regex可以直接用 `?` 与 `+`.
而在 `[]` 之内 这 `] - ^` 三个是特殊字符。
. any character (but newline)
* previous character or group, repeated 0 or more time
+ previous character or group, repeated 1 or more time
? previous character or group, repeated 0 or 1 time
^ start of line
$ end of line
[...] any character between brackets
[^..] any character not in the brackets
[a-z] any character between a and z
\ prevents interpretation of following special char
\| or
\w word constituent
\b word boundary
\sc character with c syntax (e.g. \s- for whitespace char)
\( \) start/end of group
\< \> start/end of word (faulty rendering: backslash + less-than and backslash + greater-than)
\_< \_> start/end of symbol
\` \' start/end of buffer/string
\1 string matched by the first group
\n string matched by the nth group
\{3\} previous character or group, repeated 3 times
\{3,\} previous character or group, repeated 3 or more times
\{3,6\} previous character or group, repeated 3 to 6 times
\= match succeeds if it is located at point
此处要注意的是,有 or 的操作,但是要 escape 掉。
其中 *?, +?, and ?? are non-greedy versions of *, +, and ?
另外列出语义化的semantic classes:
[:digit:] a digit, same as [0-9]
[:alpha:] a letter (an alphabetic character)
[:alnum:] a letter or a digit (an alphanumeric character)
[:upper:] a letter in uppercase
[:lower:] a letter in lowercase
[:graph:] a visible character
[:print:] a visible character plus the space character
[:space:] a whitespace character, as defined by the syntax table, but typically [ \t\r\n\v\f], which includes the newline character
[:blank:] a space or tab character
[:xdigit:] an hexadecimal digit
[:cntrl:] a control character
[:ascii:] an ascii character
[:nonascii:] any non ascii character
然后是 syntax classes:
\s- whitespace character \s/ character quote character
\sw word constituent \s$ paired delimiter
\s_ symbol constituent \s' expression prefix
\s. punctuation character \s< comment starter
\s( open delimiter character \s> comment ender
\s) close delimiter character \s! generic comment delimiter
\s" string quote character \s| generic string delimiter
\s\ escape character
当然,这些平常也用不大着。
最后是常用的emacs-commands:
C-M-s incremental forward search matching regexp
C-M-r incremental backward search matching regexp
replace-regexp replace string matching regexp
query-replace-regexp same, but query before each replacement
align-regexp align, using strings matching regexp as delimiters
highlight-regexp highlight strings matching regexp
occur show lines containing a match
multi-occur show lines in all buffers containing a match
how-many count the number of strings matching regexp
keep-lines delete all lines except those containing matches
flush-lines delete lines containing matches
grep call unix grep command and put result in a buffer
lgrep user-friendly interface to the grep command
rgrep recursive grep
dired-do-copy-regexp copy files with names matching regexp
dired-do-rename-regexp rename files matching regexp
find-grep-dired display files containing matches for regexp with Dired
- 上一篇: vi .vimrc(vi是什么意思)
- 下一篇: 深入 Linux 核心:掌握grep命令的终极指南
猜你喜欢
- 2024-09-10 oracle实用sql分享:杀进程、长时间操作等等
- 2024-09-10 走在前沿的弄潮儿,怎能不会Git的那些奇技淫巧
- 2024-09-10 TCP“三次握手,四次挥手”你真的懂吗?
- 2024-09-10 制作 deb 软件包(如何制作deb包)
- 2024-09-10 详解虚拟化之KVM概念、架构、功能、常用工具及部署
- 2024-09-10 Linux find命令一定要知道这些(linux find命令的使用)
- 2024-09-10 inux 文本处理三剑客--grep/sed/awk
- 2024-09-10 db2入门必看命令清单--日常运维必需
- 2024-09-10 浅谈Linux中的&&和ll(linux中atime)
- 2024-09-10 浅谈Linux中的&&和ll,补充&和l
- 1508℃桌面软件开发新体验!用 Blazor Hybrid 打造简洁高效的视频处理工具
- 520℃Dify工具使用全场景:dify-sandbox沙盒的原理(源码篇·第2期)
- 490℃MySQL service启动脚本浅析(r12笔记第59天)
- 469℃服务器异常重启,导致mysql启动失败,问题解决过程记录
- 467℃启用MySQL查询缓存(mysql8.0查询缓存)
- 447℃「赵强老师」MySQL的闪回(赵强iso是哪个大学毕业的)
- 427℃mysql服务怎么启动和关闭?(mysql服务怎么启动和关闭)
- 424℃MySQL server PID file could not be found!失败
- 最近发表
- 标签列表
-
- c++中::是什么意思 (83)
- 标签用于 (65)
- 主键只能有一个吗 (66)
- c#console.writeline不显示 (75)
- pythoncase语句 (81)
- es6includes (73)
- windowsscripthost (67)
- apt-getinstall-y (86)
- node_modules怎么生成 (76)
- chromepost (65)
- c++int转char (75)
- static函数和普通函数 (76)
- el-date-picker开始日期早于结束日期 (70)
- js判断是否是json字符串 (67)
- checkout-b (67)
- localstorage.removeitem (74)
- vector线程安全吗 (70)
- & (66)
- java (73)
- js数组插入 (83)
- linux删除一个文件夹 (65)
- mac安装java (72)
- eacces (67)
- 查看mysql是否启动 (70)
- 无效的列索引 (74)