help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: regex: \(.*\)\([a-zA-Z]+\)$ - not working as expected


From: K.P. Huang
Subject: Re: regex: \(.*\)\([a-zA-Z]+\)$ - not working as expected
Date: Wed, 25 Mar 2015 20:50:57 +0800

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.
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]