boyermoore package

Module contents

boyermoore.preprocess(pattern) Tuple[source]

Pre-process a pattern, for use with boyermoore_string_pp or boyermoore_file_pp.

Parameters

pattern – pattern to pre-process. Must be either str or bytes.

Returns

tuple of preprocessed data

Return type

tuple

boyermoore.search_file(pattern, filename, greedy=True) List[int][source]

Pre-process a pattern and search for all occurences inside a file.

Parameters
  • pattern – pattern to search for. Must be either str or bytes.

  • filename – name of file to search for pattern in

  • greedy (bool) – If True, all occurrences will be returned. If False, the search will stop after the first occurrence and only the first occurrence will be returned.

Returns

list of byte offsets of all occurrences that were found

Return type

[int]

boyermoore.search_file_pp(pp_data, filename, greedy=True) List[int][source]

Search for all occurrences of a pre-processed pattern inside a file.

Parameters
  • pp_data – return value from boyermoore.preprocess

  • filename (str) – name of file search for pattern in

  • greedy (bool) – If True, all occurrences will be returned. If False, the search will stop after the first occurrence and only the first occurrence will be returned.

Returns

list of byte offsets of all occurrences that were found

Return type

[int]

boyermoore.search_string(pattern, string, greedy=True) List[int][source]

Pre-process a pattern and search for all occurences inside a string.

Parameters
  • pattern – pattern to search for. Must be either str or bytes.

  • string – input data to search for pattern inside. Must be either str or bytes.

  • greedy (bool) – If True, all occurrences will be returned. If False, the search will stop after the first occurrence and only the first occurrence will be returned.

Returns

list of byte offsets of all occurrences that were found

Return type

[int]

boyermoore.search_string_pp(pp_data, string, greedy=True) List[int][source]

Search for all occurrences of a pre-processed pattern inside a string.

Parameters
  • pp_data – return value from boyermoore.preprocess

  • string – input data to search for pattern inside. Must be either str or bytes.

  • greedy (bool) – If True, all occurrences will be returned. If False, the search will stop after the first occurrence and only the first occurrence will be returned.

Returns

list of byte offsets of all occurrences that were found

Return type

[int]