{
  "schema_version": 2,
  "id": "commands/zremrangebylex",
  "title": "ZREMRANGEBYLEX",
  "url": "https://redis.io/docs/latest/commands/zremrangebylex/",
  "summary": "Removes members in a sorted set within a lexicographical range. Deletes the sorted set if all members were removed.",
  "since": "2.8.9",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-18T09:48:43+01:00",
  "page_type": "content",
  "content_hash": "a928b8106e99999e387f896916f54dbafd027e7f49df12d34af7d799cc4272a0",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command removes all elements in the sorted set stored at `key` between the lexicographical range specified by `min` and `max`.\n\nThe meaning of `min` and `max` are the same of the [`ZRANGEBYLEX`](https://redis.io/docs/latest/commands/zrangebylex) command. Similarly, this command actually removes the same elements that [`ZRANGEBYLEX`](https://redis.io/docs/latest/commands/zrangebylex) would return if called with the same `min` and `max` arguments."
    },
    {
      "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 sorted set.\n\n</details>\n\n<details open><summary><code>min</code></summary>\n\nThe minimum member, compared lexicographically. Prefix with `[` for an inclusive bound or `(` for an exclusive bound; use `-` for the lowest possible value.\n\n</details>\n\n<details open><summary><code>max</code></summary>\n\nThe maximum member, compared lexicographically. Prefix with `[` for an inclusive bound or `(` for an exclusive bound; use `+` for the highest possible value.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "redis> ZADD myzset 0 aaaa 0 b 0 c 0 d 0 e\n(integer) 5\nredis> ZADD myzset 0 foo 0 zap 0 zip 0 ALPHA 0 alpha\n(integer) 5\nredis> ZRANGE myzset 0 -1\n 1) \"ALPHA\"\n 2) \"aaaa\"\n 3) \"alpha\"\n 4) \"b\"\n 5) \"c\"\n 6) \"d\"\n 7) \"e\"\n 8) \"foo\"\n 9) \"zap\"\n10) \"zip\"\nredis> ZREMRANGEBYLEX myzset [alpha [omega\n(integer) 6\nredis> ZRANGE myzset 0 -1\n1) \"ALPHA\"\n2) \"aaaa\"\n3) \"zap\"\n4) \"zip\""
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> | <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\n[Integer reply](../../develop/reference/protocol-spec#integers): the number of members removed.\n\n**RESP3:**\n\n[Integer reply](../../develop/reference/protocol-spec#integers): Number of members removed."
    }
  ],
  "examples": []
}
