X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/163f4b8cb25ca46c1482bb6b4ca9c4c9d0f15dd4..12ebe2ac17a26ecf263f90b2acdf03db29b00223:/doc/SubstrCommand.html diff --git a/doc/SubstrCommand.html b/doc/SubstrCommand.html new file mode 100644 index 00000000..3b6bdef0 --- /dev/null +++ b/doc/SubstrCommand.html @@ -0,0 +1,51 @@ + + + + + + + +
+ + + +
+
+ +SubstrCommand: Contents
  SUBSTR _key_ _start_ _end_
    Return value
    Examples +
+ +

SubstrCommand

+ +
+ +
+ +
+ #sidebar StringCommandsSidebar

SUBSTR _key_ _start_ _end_

+Time complexity: O(start+n) (with start being the start index and n the total length of the requested range). Note that the lookup part of this command is O(1) so for small strings this is actually an O(1) command.
Return a subset of the string from offset start to offset end(both offsets are inclusive).Negative offsets can be used in order to provide an offset starting fromthe end of the string. So -1 means the last char, -2 the penultimate andso forth.
+
The function handles out of range requests without raising an error, butjust limiting the resulting range to the actual length of the string.
+

Return value

Bulk reply

Examples

+redis> set s "This is a string"
+OK
+redis> substr s 0 3
+"This"
+redis> substr s -3 -1
+"ing"
+redis> substr s 0 -1
+"This is a string"
+redis> substr s 9 100000
+" string"
+
+ +
+ +
+
+ + +