From: "K.P. Huang" <kphuanghk@gmail.com>
To: AngusC <anguscomber@gmail.com>
Cc: Help-gnu-emacs@gnu.org
Subject: Re: regex: \(.*\)\([a-zA-Z]+\)$ - not working as expected
Date: Wed, 25 Mar 2015 20:50:57 +0800 [thread overview]
Message-ID: <CAPrJVCkAP34BFqaSi_i2R1-7dQtWtKbPjn9-a04EE2_DDNUm+g@mail.gmail.com> (raw)
In-Reply-To: <1427286428315-353090.post@n5.nabble.com>
Try this one (please ignorer all the double quote):
" \([a-zA-Z]+\)$"
There is a space before first \, then replaced by
" ZZZ \1"
There is also a space before ZZZ.
Your regex will match the last char from end of line, i.e. \([a-zA-Z]+\)$.
Zero or more char follow by \(.*\). You got the right result for your regex.
-- kphuanghk
2015-03-25 20:27 GMT+08:00 AngusC <anguscomber@gmail.com>:
> 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?
>
>
>
>
> --
> View this message in context:
> http://emacs.1067599.n5.nabble.com/regex-a-zA-Z-not-working-as-expected-tp353090.html
> Sent from the Emacs - Help mailing list archive at Nabble.com.
>
>
next prev parent reply other threads:[~2015-03-25 12:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-25 12:27 regex: \(.*\)\([a-zA-Z]+\)$ - not working as expected AngusC
2015-03-25 12:50 ` K.P. Huang [this message]
2015-03-25 12:54 ` Yuri Khan
2015-03-25 14:16 ` AngusC
2015-03-25 12:57 ` tomas
[not found] <mailman.2738.1427286469.31049.help-gnu-emacs@gnu.org>
2015-03-25 12:43 ` Loris Bennett
2015-03-25 12:45 ` Loris Bennett
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=CAPrJVCkAP34BFqaSi_i2R1-7dQtWtKbPjn9-a04EE2_DDNUm+g@mail.gmail.com \
--to=kphuanghk@gmail.com \
--cc=Help-gnu-emacs@gnu.org \
--cc=anguscomber@gmail.com \
/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.