Is there a way to select the features of a map by finding text within an attribute table? For example, if several features are listed as "Nature preserve" under a column called "Category", can I select all these features using an expression like, "Category" contains '*nature*
', or something similar?
1 Answer
Using the "select by expression" tool with the following expression
regexp_match("Category",'ature') > 0
will select all features where the string "ature" is found in the column "Category". I omitted the n
because I actually don't know whether regexp is case-sensitive.
Replace "Category" with the actual name of your column.
The expression checks for > 0
because regexp_match
returns the place where the string you search for starts, or 0
if the string isn't part of the attribute. So, everything where a value unlike 0
is returned contains the string you searched for.