re-builder
re-builder是一个可用让你交互式创建正则表达式的工具. 当你在re-builder中修改正则表达式时,会动态的在buffer中用高亮显示出正则表达式的匹配范围.
re-builder支持多种格式的正则(但不支持PCRE).
启动re-builder
M-x re-builder
设置正则格式
通过设置变量`reb-re-syntax`可用设置re-builder解析的正则表达式的语法类型.
Syntax Description read default. Similar to string but requires “double escaping” of backslashes like you would be required to do in elisp. 例如"\\(bar\\)",缺点是太多\了 string recommended. Similar to read but you don’t have the issue of backslash plague that haunts the default settings. 例如" ",推荐这种方法
sregex A symbolic regular expression engine that uses s-expressions instead of strings. lisp-re Yet another regular expression engine that uses s-expressions rx A third, and far more advanced, s-expression regexp engine. Use this and not sregex or lisp-re if you want to use a lisp-style regexp engine. 操作命令
更改re-builder的正则解析语法类型
C-c TAB
在匹配正则的内容中高亮显示捕获的分组
C-c C-e会进入sub-expression mode,随后输入数字0-9表示高亮捕获的哪个分组,q表示退出该mode
切换大小写敏感
C-c C-i
在匹配的内容中遍历
C-c C-s表示下一个匹配的内容
C-c C-w表示上一个匹配的内容
保存创建的正则表达式
C-c C-w
更改target-buffer
C-c C-b,更改target-buffer后,在RE-Builder中创建的正则匹配到target buffer中的内容
退出re-builder
C-c C-q