Sorry if this is a dumb question, but I am wondering if there is a way to copy the text from one field to a new field, but eliminate specific words. For example:

**Old Field**                         **New Field**

Killbear Provincial Park               Killbear
Quetico Provincial Park                Quetico
La Cloche Provincial Park              La Cloche
Wildcat Hill Provincial Park           Wildcat Hill

I thought of trying a trim function, but not all the values have the same start location or trim length.



In your attribute table create a new string column and then use the field calculator as follows:

 replace(OLD_FIELD, 'Provincial Park','')

The problem with this approach is that your fields won't be trimmed, so you can do the following little hack to address that:

 replace(OLD_FIELD, ' Provincial Park ','')
 replace(OLD_FIELD, ' Provincial Park','')
 replace(OLD_FIELD, 'Provincial Park ','')
 replace(OLD_FIELD, 'Provincial Park','')

How about removing all the occurrences of " Provincial Park" A search/replace ought to do the trick.

  • Thank you work. I didn't know you could do a replace in QGIS, I see the Search option, but not the replace Sep 7 '12 at 13:03
  • If you're working with a shapefile, you could edit the .dbf file directly with Excel and do your search/replace there. Unfortunately newer versions of Excel (2007, 2010) no longer let you save to DBF. Would work if you have Excel 2003 or earlier.
    – Rayner
    Sep 7 '12 at 13:07
  • 2
    There's always LibreOffice Calc which handles DBF files just fine.
    – n1kn0k
    Mar 6 '13 at 3:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.