Substitution problem

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Substitution problem

Bouckaert, Hugo

Hi

I have a minor irritating problem with substitution I can't seem to get
right. I want to substitute:

:%s/lv_postal_street/r_bio.postal_street/g

But the problem is that I also have a string "lv_postal_street2" so that
for lv_postal_street2 it also substitutes "r_bio.postal_street".

I tried

:%s/lv_postal_street[^2]/r_bio.postal_street/g
 
i.e. "lv_postal_street", "not followed by 2" but it does not work.

Any ideas?

Thanks

Hugo

 
Hugo Bouckaert
Oracle Analyst / Programmer
Two's Complement Computing
--------------------------------------------------
This email and any attachments may be confidential or legally
privileged. If you received this message in error or are not the
intended recipient, you should destroy the e-mail message and any
attachments or copies, and you are prohibited from retaining,
distributing, disclosing or using any information contained herein.
Please inform us of the erroneous delivery by return e-mail. Thank you
for your cooperation.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Substitution problem

Marian Csontos
On Wed, 31 Aug 2005 10:43:50 +0200, Bouckaert, Hugo  
<[hidden email]> wrote:

>
> Hi
>
> I have a minor irritating problem with substitution I can't seem to get
> right. I want to substitute:
>
> :%s/lv_postal_street/r_bio.postal_street/g
>
> But the problem is that I also have a string "lv_postal_street2" so that
> for lv_postal_street2 it also substitutes "r_bio.postal_street".
>
> I tried
>
> :%s/lv_postal_street[^2]/r_bio.postal_street/g
> i.e. "lv_postal_street", "not followed by 2" but it does not work.
>
> Any ideas?
>
> Thanks
>
> Hugo
>

Hi,

try

:%s/\<lv_postal_street\>/.../g

\< and \> find word boudaries.
:he \<
:he \>


Regards

-- Marian



________ Information from NOD32 ________
This message was checked by NOD32 Antivirus System for Linux Mail Server.
http://www.nod32.com
Reply | Threaded
Open this post in threaded view
|

RE: Substitution problem

ehannes
In reply to this post by Bouckaert, Hugo
use
:%s/lv_postal_street\(2\)\@!/r_bio.postal_street/g


Hans Scholte, <DPC/>



-----Oorspronkelijk bericht-----
Van: Marian Csontos [mailto:[hidden email]]
Verzonden: woensdag 31 augustus 2005 11:38
Aan: Bouckaert, Hugo; [hidden email]
Onderwerp: Re: Substitution problem


On Wed, 31 Aug 2005 10:43:50 +0200, Bouckaert, Hugo  
<[hidden email]> wrote:

>
> Hi
>
> I have a minor irritating problem with substitution I can't seem to get
> right. I want to substitute:
>
> :%s/lv_postal_street/r_bio.postal_street/g
>
> But the problem is that I also have a string "lv_postal_street2" so that
> for lv_postal_street2 it also substitutes "r_bio.postal_street".
>
> I tried
>
> :%s/lv_postal_street[^2]/r_bio.postal_street/g
> i.e. "lv_postal_street", "not followed by 2" but it does not work.
>
> Any ideas?
>
> Thanks
>
> Hugo
>

Hi,

try

:%s/\<lv_postal_street\>/.../g

\< and \> find word boudaries.
:he \<
:he \>


Regards

-- Marian



________ Information from NOD32 ________
This message was checked by NOD32 Antivirus System for Linux Mail Server.
http://www.nod32.com
Reply | Threaded
Open this post in threaded view
|

RE: Substitution problem

Keith W. Roberts
In reply to this post by Bouckaert, Hugo
 

> -----Original Message-----
> From: Bouckaert, Hugo [mailto:[hidden email]]
> Sent: Wednesday, August 31, 2005 1:44 AM
> To: [hidden email]
> Subject: Substitution problem
>
>
> Hi
>
> I have a minor irritating problem with substitution I can't
> seem to get
> right. I want to substitute:
>
> :%s/lv_postal_street/r_bio.postal_street/g
>
> But the problem is that I also have a string
> "lv_postal_street2" so that
> for lv_postal_street2 it also substitutes "r_bio.postal_street".
>
> I tried
>
> :%s/lv_postal_street[^2]/r_bio.postal_street/g
>  
> i.e. "lv_postal_street", "not followed by 2" but it does not work.
>
> Any ideas?

You got two great answers, but I thought I'd amplify.  The reason your
original didn't work was that [^2] specifies that there *must* be a
character following the rest of the string, just not a '2'.

-Keith