ARGREP
ARGREP key start end <EXACT string | MATCH string | GLOB pattern | RE pattern [...]> [AND | OR | LIMIT limit | WITHVALUES | NOCASE [...]]
- Available since:
- Redis Open Source 8.8.0
- Time complexity:
- O(P * C) where P is the number of visited positions in touched slices and C is the cost of evaluating the predicates on one existing element.
- ACL categories:
-
@array,
Searches array elements in a range using textual predicates and returns the indices of the matching elements. Empty slots in the range are skipped.
Required arguments
key
The name of the key that holds the array.
start
The 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.
end
The zero-based integer index at which to stop searching (inclusive). The special value + denotes the last index of the array.
predicate
One or more textual predicates to evaluate against each non-empty element in the range. Each predicate is one of:
EXACT string— Matches elements whose value is exactly equal tostring.MATCH string— Matches elements whose value containsstringas a substring.GLOB pattern— Matches elements whose value matches the glob-stylepattern(with*,?, and[...]wildcards), the same syntax used byKEYSandSCANMATCH.RE pattern— Matches elements whose value matches the regular expressionpattern.
When more than one predicate is supplied, use the AND or OR option to control how they are combined. The default is OR.
Optional arguments
options
Zero or more of the following modifiers:
AND— Combine multiple predicates with logical AND. An element matches only if every predicate matches.OR— Combine multiple predicates with logical OR. An element matches if any predicate matches. This is the default.LIMIT limit— Stop afterlimitmatches have been collected.limitmust be a positive integer. When omitted, all matches in the range are returned.WITHVALUES— In addition to each matching index, return the matching value. The reply becomes a flat list of alternating index-value pairs.NOCASE— Perform case-insensitive comparisons forEXACT,MATCH,GLOB, andRE.
Examples
Return information
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.