mirror of
https://github.com/zeek/zeek.git
synced 2025-10-16 21:48:21 +00:00

The index expression can take up to two indices for the start and end index of the substring to return (e.g. "mystring[1,3]"). Negative indices are allowed, with -1 representing the last character in the string. The indexing is not cyclic -- if the starting index is >= the length of the string an empty string is returned, and if the ending index is >= the length of the string then it's interpreted as the last index of the string. Assigning to substrings accessed like this isn't allowed.
17 lines
292 B
Text
17 lines
292 B
Text
# @TEST-EXEC: bro -b %INPUT >out
|
|
# @TEST-EXEC: btest-diff out
|
|
|
|
local s = "0123456789";
|
|
print s[1];
|
|
print s[1,2];
|
|
print s[1,6];
|
|
print s[0,20];
|
|
print s[-2];
|
|
print s[-3,-1];
|
|
print s[-1,-10];
|
|
print s[-1,0];
|
|
print s[-1,5];
|
|
print s[20, 23];
|
|
print s[-20, 23];
|
|
print s[0,5][2];
|
|
print s[0,5][1,3][0];
|