From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Loris Bennett" Newsgroups: gmane.emacs.help Subject: Re: regex: \(.*\)\([a-zA-Z]+\)$ - not working as expected Date: Wed, 25 Mar 2015 13:45:39 +0100 Organization: ZEDAT, Freie =?utf-8?Q?Universit=C3=A4t?= Berlin Message-ID: <87zj71mej0.fsf@hornfels.zedat.fu-berlin.de> References: <874mp9nt7l.fsf@hornfels.zedat.fu-berlin.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1427287831 26360 80.91.229.3 (25 Mar 2015 12:50:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 25 Mar 2015 12:50:31 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Mar 25 13:50:31 2015 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 1YaklM-0001AC-En for geh-help-gnu-emacs@m.gmane.org; Wed, 25 Mar 2015 13:50:24 +0100 Original-Received: from localhost ([::1]:38828 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YaklG-0007Sc-VF for geh-help-gnu-emacs@m.gmane.org; Wed, 25 Mar 2015 08:50:18 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 48 Original-X-Trace: news.uni-berlin.de kBJCUxPsarNjJSLthvMQeQmGduqsnBfjCTN2J5P4BQO3dN Cancel-Lock: sha1:QmsWmID6EpnT8prvTqfA0pFKtuM= User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:211030 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:103311 Archived-At: "Loris Bennett" writes: > AngusC writes: > >> I have text like this: >> >> some description here Status1 >> some other description Status2 >> some other interesting description Status1 >> >> I am using regex like this: >> >> \(.*\)\([a-zA-Z]+\)$ >> >> with replacement text: >> >> \1 ZZZ \2 >> >> And what I expected was: >> >> some description here ZZZ Status >> some other description ZZZ Fault >> some other interesting description ZZZ Status >> >> But instead I got: >> >> some description here Statu ZZZ s >> some other description Faul ZZZ t >> some other interesting description Statu ZZZ s >> >> I want my expected outcome, how do I do that? >> >> What was wrong with my regex? > > Your first group is matching right up to the last penultimate character Sorry, that should just be "the penultimate character". > and the second is match the last character. Try adding a patter to > match a space between your groups. > > Cheers, > > Loris -- Dr. Loris Bennett (Mr.) ZEDAT, Freie Universität Berlin Email loris.bennett@fu-berlin.de