{
  "id": "argrep",
  "title": "ARGREP",
  "url": "https://redis.io/docs/latest/commands/argrep/",
  "summary": "Searches array elements in a range using textual predicates.",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-05-25T10:30:01-07:00",
  "page_type": "content",
  "content_hash": "4c18996d47f32904bc92c5c2871f86ed2aefd686d3ca7a693412e62924f08df6",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Searches array elements in a range using textual predicates and returns the indices of the matching elements. Empty slots in the range are skipped."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary>\n\nThe name of the key that holds the array.\n\n</details>\n\n<details open><summary><code>start</code></summary>\n\nThe zero-based integer index at which to begin searching. The special value `-` denotes the first index of the array. If `start` is greater than `end`, matches are returned in reverse index order.\n\n</details>\n\n<details open><summary><code>end</code></summary>\n\nThe zero-based integer index at which to stop searching (inclusive). The special value `+` denotes the last index of the array.\n\n</details>\n\n<details open><summary><code>predicate</code></summary>\n\nOne or more textual predicates to evaluate against each non-empty element in the range. Each predicate is one of:\n\n- **`EXACT string`** — Matches elements whose value is exactly equal to `string`.\n- **`MATCH string`** — Matches elements whose value contains `string` as a substring.\n- **`GLOB pattern`** — Matches elements whose value matches the glob-style `pattern` (with `*`, `?`, and `[...]` wildcards), the same syntax used by [`KEYS`](https://redis.io/docs/latest/commands/keys) and [`SCAN`](https://redis.io/docs/latest/commands/scan) `MATCH`.\n- **`RE pattern`** — Matches elements whose value matches the regular expression `pattern`.\n\nWhen more than one predicate is supplied, use the `AND` or `OR` option to control how they are combined. The default is `OR`.\n\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "<details open><summary><code>options</code></summary>\n\nZero or more of the following modifiers:\n\n- **`AND`** — Combine multiple predicates with logical AND. An element matches only if every predicate matches.\n- **`OR`** — Combine multiple predicates with logical OR. An element matches if any predicate matches. This is the default.\n- **`LIMIT limit`** — Stop after `limit` matches have been collected. `limit` must be a positive integer. When omitted, all matches in the range are returned.\n- **`WITHVALUES`** — In addition to each matching index, return the matching value. The reply becomes a flat list of alternating index-value pairs.\n- **`NOCASE`** — Perform case-insensitive comparisons for `EXACT`, `MATCH`, `GLOB`, and `RE`.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "ARMSET log 0 \"boot: ok\" 1 \"warn: disk\" 2 \"ERROR: cpu\" 3 \"info: ready\" 4 \"error: net\"\nARGREP log - + MATCH \"error\" NOCASE\nARGREP log - + MATCH \"error\" NOCASE WITHVALUES\nARGREP log 0 4 GLOB \"warn:*\" OR GLOB \"error:*\"\nARGREP log 0 4 RE \"^[A-Za-z]+: (cpu|net)$\" NOCASE WITHVALUES\nARGREP log 0 4 EXACT \"info: ready\"\nARGREP log - + MATCH \"error\" NOCASE LIMIT 1"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\n[Array reply](../../develop/reference/protocol-spec#arrays): Indices of the matching elements, in the same order in which the range is traversed (ascending when `start <= end`, descending when `start > end`). When `WITHVALUES` is given, a flat array of alternating index-value pairs: `[idx1, val1, idx2, val2, ...]`. An empty array is returned when the key does not exist or no element matches.\n\n**RESP3:**\n\n[Array reply](../../develop/reference/protocol-spec#arrays): Indices of the matching elements, in the same order in which the range is traversed (ascending when `start <= end`, descending when `start > end`). When `WITHVALUES` is given, a flat array of alternating index-value pairs: `[idx1, val1, idx2, val2, ...]`. An empty array is returned when the key does not exist or no element matches."
    }
  ],
  "examples": []
}
