all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Loris Bennett" <loris.bennett@fu-berlin.de>
To: help-gnu-emacs@gnu.org
Subject: Re: regex: \(.*\)\([a-zA-Z]+\)$ - not working as expected
Date: Wed, 25 Mar 2015 13:43:10 +0100	[thread overview]
Message-ID: <874mp9nt7l.fsf@hornfels.zedat.fu-berlin.de> (raw)
In-Reply-To: mailman.2738.1427286469.31049.help-gnu-emacs@gnu.org

AngusC <anguscomber@gmail.com> 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.


       reply	other threads:[~2015-03-25 12:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.2738.1427286469.31049.help-gnu-emacs@gnu.org>
2015-03-25 12:43 ` Loris Bennett [this message]
2015-03-25 12:45   ` regex: \(.*\)\([a-zA-Z]+\)$ - not working as expected Loris Bennett
2015-03-25 12:27 AngusC
2015-03-25 12:50 ` K.P. Huang
2015-03-25 12:54 ` Yuri Khan
2015-03-25 14:16   ` AngusC
2015-03-25 12:57 ` tomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874mp9nt7l.fsf@hornfels.zedat.fu-berlin.de \
    --to=loris.bennett@fu-berlin.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.