contains operator

Filters a record set for data containing a case-insensitive string. contains searches for arbitrary sub-strings rather than terms.

The following table compares the contains operators using the abbreviations provided:

  • RHS = right-hand side of the expression
  • LHS = left-hand side of the expression
Operator Description Case-Sensitive Example (yields true)
contains RHS occurs as a subsequence of LHS No "FabriKam" contains "BRik"
!contains RHS doesn't occur in LHS No "Fabrikam" !contains "xyz"
contains_cs RHS occurs as a subsequence of LHS Yes "FabriKam" contains_cs "Kam"
!contains_cs RHS doesn't occur in LHS Yes "Fabrikam" !contains_cs "Kam"

For more information about other operators and to determine which operator is most appropriate for your query, see datatype string operators.

Performance tips

Note

Performance depends on the type of search and the structure of the data. For best practices, see Query best practices.

When possible, use contains_cs - a case-sensitive version of the operator.

If you're looking for a term, use has for faster results.

Syntax

T | where col contains_cs (string)

Learn more about syntax conventions.

Parameters

Name Type Required Description
T string ✔️ The tabular input whose records are to be filtered.
col string ✔️ The name of the column to check for string.
string string ✔️ The case-sensitive string by which to filter the data.

Returns

Rows in T for which string is in col.

Example

StormEvents
| summarize event_count=count() by State
| where State contains "enn"
| where event_count > 10
| project State, event_count
| render table

Output

State event_count
PENNSYLVANIA 1687
TENNESSEE 1125