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:43:10 +0100 Organization: Freie Universitaet Berlin Message-ID: <874mp9nt7l.fsf@hornfels.zedat.fu-berlin.de> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1427287522 21151 80.91.229.3 (25 Mar 2015 12:45:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 25 Mar 2015 12:45:22 +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:45:22 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 1YakgR-0006D4-U6 for geh-help-gnu-emacs@m.gmane.org; Wed, 25 Mar 2015 13:45:20 +0100 Original-Received: from localhost ([::1]:38788 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YakgR-0002tU-8p for geh-help-gnu-emacs@m.gmane.org; Wed, 25 Mar 2015 08:45:19 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 42 Original-X-Trace: news.uni-berlin.de vXoSVHWRgIDr82ukiOVUsQ/4k/Qvl8H/OsQnK0Q5awQU5O Cancel-Lock: sha1:n5+cCYIBLQneYt2MOd+sa5sW7h0= User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:211029 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:103310 Archived-At: 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 and the second is match the last character. Try adding a patter to match a space between your groups. Cheers, Loris -- This signature is currently under construction.