I am using QGIS 2.18.
I have a point shapefile showing ranger stations in a park. The attached image is the field I want to use to label my points. I want to omit "Ranger Station" from showing in the label on the map.
You can use the the strpos function for this if the name Ranger Stations is always constant.
substr( "LOC_NAME" , 0, strpos( "LOC_NAME", 'Ranger Station'))
The function strpos prints out the string between the given start and endposition. Startposition is easy and set to 0. The end position is delivered by the function strpos. This function delivers the first occurence of the search string. Thats your endposition for the substr function.
In your Layer Properties dialogue box, fill in the Label with box with the name of your column (LOC_NAME) (osm_type in my example), and click the Sigma button to the right (circled in red in the image below).
In the new dialogue box that opens, you can write a string query to get rid of your unwanted text. Your query will probably be
replace(LOC_NAME, ' Ranger Station', '')
The first argument is the input string, the second is the text that you want replaced, and the third is what you want it replaced with. In your example, you want the unwanted text replaced with nothing, so you put in two single quotes with nothing between them. (Note also that you probably want to get rid of the space that is currently between the text you want and "Ranger Station," so I included an extra space within the single quotes of the second argument:
' Ranger Station'.
@Matte has a better solution than the one that I am going to post here, but I will post it anyway.
I used a substr & length expression instead.
I am labeling my map with the name field, which has the word "Permit" at the end of each valid field.
I do not want the word "Permit" included in my labels, so in the expression builder of the Labeling dialog, I entered this.
This gets the length of the name field, and I simply counted the the characters I wanted to subtract from the name field for labeling.
Here is the result.