I would need to label a layer excluding specific features based on the value of an attribute, ie 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 rue-based option with an expression like "NOME" NOT LIKE '% [_]FIUME%' but without success (all features are found). How can i solve the problem?

  • For clarificatipn: Would you like the small rivers to simply be labeled "Fiume" or to have no label at all? – Erik Jul 11 '18 at 10:22
  • "NOME" NOT LIKE '%FIUME%' doesn't work? – Carlos López Quintanilla Jul 11 '18 at 10:35
  • Thanks, 1 - no label at all. 2 - the values that I have to exclude have format 'xxxxxx_FIUME_xxxxx' or 'FIUME_xxxxx' or 'xxxxxx_CANALE_xxxxx' and so on but there may be valid values like 'FIUME TEMO' – Andrew-63 Jul 11 '18 at 11:41

If you choose rulebased labeling, you can use for example the following expression as a filter to rule out all labels containing "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


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

| improve this answer | |
  • thanks, therefore the rule to insert would be: NOT(regexp_match("NOME",'FIUME')) and if I had more values to exclude in the same rule it could be NOT(regexp_match("NOME",'FIUME_','CANALE_'))? – Andrew-63 Jul 11 '18 at 11:46
  • 1
    Nope, you can only check for one argument/string with regexp. You'd have to build subrules in order to check for other strings. – Erik Jul 11 '18 at 12:49
  • 1
    OK, seems to work with NOT (( regexp_match( "NOME" , 'FIUME_' )) OR (regexp_match( "NOME" , 'CANALE_' ))), Thanks a lot! – Andrew-63 Jul 11 '18 at 15:08
  • Yeah, OR is the most obvious answer^^ glad to help – Erik Jul 12 '18 at 11:26

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.