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:45:39 +0100 [thread overview]
Message-ID: <87zj71mej0.fsf@hornfels.zedat.fu-berlin.de> (raw)
In-Reply-To: 874mp9nt7l.fsf@hornfels.zedat.fu-berlin.de
"Loris Bennett" <loris.bennett@fu-berlin.de> writes:
> 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
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
next prev parent reply other threads:[~2015-03-25 12:45 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 ` regex: \(.*\)\([a-zA-Z]+\)$ - not working as expected Loris Bennett
2015-03-25 12:45 ` Loris Bennett [this message]
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zj71mej0.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).