tags:

views:

50

answers:

1

Example code:

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

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?

+2  A: 

This works for me:

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

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

scottfrazer