[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Regarding replacing regexp
From: |
XeCycle |
Subject: |
Re: Regarding replacing regexp |
Date: |
Fri, 11 May 2012 10:57:15 +0800 |
User-agent: |
Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1.50 (gnu/linux) |
Deniz Dogan <deniz@dogan.se> 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
pgpvBzBDWHcme.pgp
Description: PGP signature