Emacs的调整,正则表达式用&QUOT工作; =" [英] Emacs align-regexp working with "="

查看:609
本文介绍了Emacs的调整,正则表达式用&QUOT工作; ="的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如code:

f x
  | "s" == x = 1
  | otherwise = 0

我可以看到正则表达式是匹配时由空白字符包围等号。但是,\ S - + = \ S- +不起作用(\ S-+是图案1+空格),因为它结束了插入额外的空间之前等号。我需要一个图案,上面写着匹配空字符串时,有空格在这里,但不知道如何做到这一点?

I can see the regexp as "match the equals sign when surrounded by whitespace characters". However, \s-+=\s-+ doesn't work (\s-+ is the pattern for 1+ whitespace) because it ends up inserting an extra space before the equals sign. I need a pattern that says "match empty string when there is whitespace here", but not sure how to do this?

推荐答案

这对我的作品:

C-u M-x align-regexp RET \(\s-+\)=\s- RET RET RET n

请注意了 + 的括号内,默认有 *

Note the '+' inside the parens, the default has '*'

这篇关于Emacs的调整,正则表达式用&QUOT工作; ="的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆