Replacing Whole Words Only using @replace

4 posts / 0 new
Last post
Gerard Usher
Offline
Joined: 10/26/2018 - 08:40
Replacing Whole Words Only using @replace

Hi All!
 
I'm trying to use @ replace to clean up a big Vendor Liost by replacing some common Company Names with "" (essentially removing the bits I don't want).
 
When I use Add Virtual Charachter and the parameters below, it removes parts of words, as well as whole words. How can I tell IDEA to replace Whole Words Only?
 
@replace(@replace(@replace(@replace(SUP_NAME, "CO", "" ),"AS", "" ),"AGENCY" ,  "" ),"AGENCIES" , "" ) 
 
In this example above "DALLAS COUNTY AUDITOR" becomes "DALL UNTY AUDITOR"
 

scotchy33
Offline
Joined: 09/05/2012 - 15:51

Use spaces or regular expression (@RegExpr).

@replace(@replace(@replace(@replace(SUP_NAME, " CO ", "" )," AS ", "" )," AGENCY" ,  "" )," AGENCIES" , "" ) 

Gerard Usher
Offline
Joined: 10/26/2018 - 08:40

Thanks for the advice scotchy 33. How would that work in my example?

scotchy33
Offline
Joined: 09/05/2012 - 15:51

I would go in equation editor and read about @RegExpr and play with it a bit.