QGIS 3x - categorized style customization based on a part of the string

You did not specify the value which triggers whether your polygon should go into the first group or not - "TITLE" LIKE %SE-2% returns 1 for true and 0 for false. instead of "all other Values", set one colour to 1 and one to 0.


In addition to Cyrmel: The formula is "TITLE" LIKE '%SE-2%' and than you have to classify (to 1/0 or true/false). If you want, you can also change manually the 0 and 1 in the legend.

enter image description here


Assuming Consistent Formatting in TITLE Field

The expression substr("TITLE", 4, 1) returns the fourth character of the string. If the TITLE field is consistently formatted, this will correspond to the particular category, either 1 or 2. Just enter that expression and click classify.

categorize on substring

Alternatively, you could modify substr's starting position and length, or if the SE-# is always at the beginning, simply use left("TITLE", 4) to get the SE-# text, not just the number.

categorize on longer substring

Inconsistent Formatting in TITLE Field

If the SE-# text does not consistently appear at the beginning of the string, you can use the regex_substr function. This is easiest for grabbing the entire SE-# text, but can be modified to grab just the number, or you can nest it within a right function instead.

regexp_substr("TITLE", 'SE-[1,2]')

regex substring