QGIS – How to Display Features or Labels Containing a Certain Word

expressionprint-composerqgisqgis-3

I have a column "name" and on it is contains several row like

  • Candra Hotel
  • Ibis Hotel
  • Season park
  • Central park Mall
  • Boom Mall
  • Johor market

I want to display names that only contain word "mall" on it, what is the formula for that filtering in QGIS?

Best Answer

Case sensitive

Use this expression to evaluate if the field "name" contains the string Mall (does not find mall etc.):

"name" LIKE '%Mall%' or alternatively strpos("name",'Mall')>0

Ignore case of first character

Be aware that the above solution is case sensitive, finding Mall, but not mall. To include both versions, use:

regexp_match("name",('M|mall'))>0

Ignore case completey

To find variants like Mall, mall, MALL, MAll, maLL, MaLl etc., use:

lower("name") LIKE '%mall%' or "name" ILIKE '%mall%' or regexp_match("name",'(?i:mall)') - see here for this last syntax

QGIS expression functions reference

See the help of the functions used here:

Related Question