Deniz Dogan writes: > On 2012-05-10 11:37, shirish wrote: >> Hi, >> >> I am in the process of learning how to use emacs. I know about the >> replace-regexp but I am unable to create a regular expression to do the >> below. >> Any help is much appreciated. >> >> public static final String SUCCESS //Successmesg >> public static final String FAILURE //failuremessage >> >> I need to replace that with >> >> public static final String SUCCESS = "SUCCESS";//Successmesg >> public static final String FAILURE = "FAILURE"; //failuremessage >> >> Thanks, >> Shirish. >> >> > > There are a lot of ways to do it. One could be: > > String \([^ ]+\) > > and replace it with: > > String \1 = "\1" This won't do very well. Try: SUCCESS\|FAILURE => \& = "\&"; I may be wrong about those escapes, try it. > I would personally use keyboard macros for it. Yes, This would be fine, too. And usually easier than regexps. -- Carl Lei (XeCycle) Department of Physics, Shanghai Jiao Tong University OpenPGP public key: 7795E591 Fingerprint: 1FB6 7F1F D45D F681 C845 27F7 8D71 8EC4 7795 E591