I want to create rule based labeling for a layer where I want to label any features that have "private" anywhere in the value under "ROAD_NAME"

So if I had Values:

Highway 1 Highway 2 Road 1 Road 2 Private 1 Private 2

I want to label all values except the ones that have "private" anywhere in their name. Is there an expression that uses a wildcard character or something similar to do this?

1 Answer 1


You should be able to use the regexp_match function under String in the expression builder to do this.

Something like:

  NOT (regexp_match( "ROAD_NAME",'\\bPrivate\\b') >= 0)

while find all the features where "ROAD_NAME" doesn't contain Private as a single word.

  • What is the \\b for?
    – GreyHippo
    Aug 17, 2018 at 1:59
  • it is a word boundary marker, this makes sure that words containing private don't get matched
    – Ian Turton
    Aug 17, 2018 at 7:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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