Skip to content

Latest commit

 

History

History
85 lines (66 loc) · 2.18 KB

bytes_index-of.md

File metadata and controls

85 lines (66 loc) · 2.18 KB
title categories version bytes usage feature
bytes index-of
bytes
0.94.0
Returns start index of first occurrence of pattern in bytes, or -1 if no match.
Returns start index of first occurrence of pattern in bytes, or -1 if no match.
default

bytes index-of for bytes

Returns start index of first occurrence of pattern in bytes, or -1 if no match.

Signature

> bytes index-of {flags} (pattern) ...rest

Flags

  • --all, -a: returns all matched index
  • --end, -e: search from the end of the binary

Parameters

  • pattern: The pattern to find index of.
  • ...rest: For a data structure input, find the indexes at the given cell paths.

Input/output types:

input output
binary any
record record
table table

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 --end 0x[44 55]
6

Returns all matched index

>  0x[33 44 55 10 01 33 44 33 44] | bytes index-of --all 0x[33 44]
╭───┬───╮
│ 00 │
│ 15 │
│ 27 │
╰───┴───╯

Returns all matched index, searching from end

>  0x[33 44 55 10 01 33 44 33 44] | bytes index-of --all --end 0x[33 44]
╭───┬───╮
│ 07 │
│ 15 │
│ 20 │
╰───┴───╯

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 │
├───┼──────┼──────────────┼──────┤
│ 00 │ [20, 21, 22] │   -1 │
╰───┴──────┴──────────────┴──────╯