bytes index-of
for bytes
Returns start index of first occurrence of pattern in bytes, or -1 if no match.
Signature
> bytes index-of (pattern) ...rest --all --end
Parameters
pattern
: the pattern to find index of...rest
: for a data structure input, find the indexes at the given cell paths--all
(-a)
: returns all matched index--end
(-e)
: search from the end of the binary
Examples
Returns index of pattern in bytes
> 0x[33 44 55 10 01 13 44 55] | bytes index-of 0x[44 55]
1
Returns index of pattern, search from end
> 0x[33 44 55 10 01 13 44 55] | bytes index-of -e 0x[44 55]
6
Returns all matched index
> 0x[33 44 55 10 01 33 44 33 44] | bytes index-of -a 0x[33 44]
╭───┬───╮
│ 0 │ 0 │
│ 1 │ 5 │
│ 2 │ 7 │
╰───┴───╯
Returns all matched index, searching from end
> 0x[33 44 55 10 01 33 44 33 44] | bytes index-of -a -e 0x[33 44]
╭───┬───╮
│ 0 │ 7 │
│ 1 │ 5 │
│ 2 │ 0 │
╰───┴───╯
Returns index of pattern for specific column
> [[ColA ColB ColC]; [0x[11 12 13] 0x[14 15 16] 0x[17 18 19]]] | bytes index-of 0x[11] ColA ColC
╭───┬──────┬──────────────┬──────╮
│ # │ ColA │ ColB │ ColC │
├───┼──────┼──────────────┼──────┤
│ 0 │ 0 │ [20, 21, 22] │ -1 │
╰───┴──────┴──────────────┴──────╯