Re: st: replace and strpos

I have a list of around 300 postcodes that are string variables. I need
to change the postcode strings into their corresponding borough. I
succeeded in doing this to some extent by writing commands for each
string value using replace and strops. E.g.:

replace borough = "Camden" if strpos(postcode, "NW1")

A problem arises when I run all the commands and it comes to a postcode
that contains some characters that are also in another postcode, i.e. it
overwrites the original.

E.g. the above "Camden" is overwritten by "Westminster" when this
command is run:

replace borough = "Westminster" if strpos(postcode, "W1")
Because it shares the "W1".

Is there any way I can tell Stata to look for the EXACT postcode? I've
looked all around and can't figure it out.