QGIS – How to Label a Layer by Excluding Specific Features

expressionlabelingqgis

I would need to label a layer excluding specific features based on the value of an attribute, i.e.
enter image description here
enter image description here

I would not want to appear the labels like 'xxxxxx_FIUME_xxxxx' or 'FIUME_xxxxx' etc.
I tried using the rule-based option with an expression like "NOME" NOT LIKE '% [_]FIUME%' but without success (all features are found).
How can I solve the problem?

Best Answer

If you choose rulebased labeling, you can use for example the following expression as a filter to rule out all labels containing "fiume"

NOT(regexp_match("NOME",'FIUME'))

This gives you all rivers not containing the string "fiume", then you simply tell QGis how to label these. Then you also have to "catch" all the rivers containing the "fiume"-string

regexp_match("NOME",'FIUME')

And now tell QGis to not to label these, or maybe label with the same shortened expression for all small rivers.

Related Question