Skip to main content
The table summarizes the string operators available in APL. RHS = right-hand side of the expression LHS = left-hand side of the expression

Case-sensitivity

Operators with _cs suffix are case-sensitive. When two operators do the same task, use the case-sensitive one for better performance. For example:
  • Instead of =~, use ==
  • Instead of in~, use in
  • Instead of contains, use contains_cs

Best practices

  • Use case-sensitive operators when you know the case to improve performance.
  • Avoid complex regular expressions for basic matching tasks. Use basic string operators instead.
  • When matching against a set of values, ensure the set is as small as possible to improve performance.
  • For matching substrings, use prefix or suffix matching instead of general substring matching for better performance.

Equality and inequality operators

Operators:
  • ==
  • !=
  • =~
  • !~
  • in
  • !in
  • in~
  • !in~
Query examples:
  • Use == or != for exact match comparisons when case sensitivity is important.
  • Use =~ or !~ for case-insensitive comparisons or when you don’t know the exact case.
  • Use in or !in for checking membership within a set of values which can be efficient for a small set of values.

Subsequence-matching operators

Operators:
  • contains
  • !contains
  • contains_cs
  • !contains_cs
  • startswith
  • !startswith
  • startswith_cs
  • !startswith_cs
  • endswith
  • !endswith
  • endswith_cs
  • !endswith_cs
Query examples:
Use case-sensitive operators (contains_cs, startswith_cs, endswith_cs) when you know the case to improve performance.

Regular-expression-matching operators

Operators:
  • matches regex
  • !matches regex
Query examples:
Avoid complex regular expressions or use string operators for simple substring, prefix, or suffix matching.

Term-matching operators

Operators:
  • has
  • !has
  • has_cs
  • !has_cs
  • hasprefix
  • !hasprefix
  • hasprefix_cs
  • !hasprefix_cs
  • hassuffix
  • !hassuffix
  • hassuffix_cs
  • !hassuffix_cs
Query examples:
  • Use has or has_cs for term matching which can be more efficient than regular expression matching for simple term searches.
  • Use has_cs when you know the case to improve performance.
  • Unlike the contains operator, which matches any substring, the has operator looks for exact terms, ensuring more precise results.