From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: XeCycle Newsgroups: gmane.emacs.help Subject: Re: Regarding replacing regexp Date: Fri, 11 May 2012 10:57:15 +0800 Message-ID: <874nrnqvas.fsf@xc.laptop> References: <4FABEC39.6060305@dogan.se> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: dough.gmane.org 1336705245 29721 80.91.229.3 (11 May 2012 03:00:45 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 11 May 2012 03:00:45 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri May 11 05:00:45 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SSg61-0001eL-3K for geh-help-gnu-emacs@m.gmane.org; Fri, 11 May 2012 05:00:45 +0200 Original-Received: from localhost ([::1]:57490 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSg60-00026l-Hz for geh-help-gnu-emacs@m.gmane.org; Thu, 10 May 2012 23:00:44 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:34024) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSg5u-00026b-As for help-gnu-emacs@gnu.org; Thu, 10 May 2012 23:00:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SSg5s-0000dD-Mj for help-gnu-emacs@gnu.org; Thu, 10 May 2012 23:00:37 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:39499) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSg5s-0000d3-G0 for help-gnu-emacs@gnu.org; Thu, 10 May 2012 23:00:36 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SSg5p-0001aC-KW for help-gnu-emacs@gnu.org; Fri, 11 May 2012 05:00:33 +0200 Original-Received: from 59.78.37.25 ([59.78.37.25]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 11 May 2012 05:00:33 +0200 Original-Received: from XeCycle by 59.78.37.25 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 11 May 2012 05:00:33 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 68 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 59.78.37.25 User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1.50 (gnu/linux) Cancel-Lock: sha1:Hg0hl5uB5F/F0DN3v1eM8EtfDqY= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:84802 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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 =3D "SUCCESS";//Successmesg >> public static final String FAILURE =3D "FAILURE"; //failuremessage >> >> Thanks, >> Shirish. >> >> > > There are a lot of ways to do it. One could be: > > String \([^ ]+\) > > and replace it with: > > String \1 =3D "\1" This won't do very well. Try: SUCCESS\|FAILURE =3D> \& =3D "\&"; 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. =2D-=20 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 --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) iQEcBAEBAgAGBQJPrIAOAAoJEI1xjsR3leWRLjMH/jPq9uu8O9s/XKUacM8jp/+u +ghe8NdTkrXqYFtr1ToIlIft17TzcmdNLeV1tfpEPJbAsccc391aCZnXK9AfaGOp SuSeTatBBvo5Qsh0vKM1UyUSgUG8k4Rq2dGjhlgpl76pllT65K084A4ZsQxRFyo8 O6kr/Anxl2r+9MxmkTnP1Rv2RK1U8/cfU5nNcu2Jq9mphrZ5z+sluIzr8LYT2vih xjjXfmniCWqncH6NfTk94ugfQvbahE5YRDdGQnBy5d8pFgeL43f3bBjzGHuDY5Pi YmEl8AI+U54Z9Q42/DGLipjRzBZvQ2cvd0ZNvyX02hMOdmsUXXYdKV2iD1Gg3jA= =7A4E -----END PGP SIGNATURE----- --=-=-=--