find_range_between_delimiters

Function find_range_between_delimiters 

Source
pub fn find_range_between_delimiters(
    text: &str,
    start_delimiter: &str,
    end_delimiter: &str,
) -> Option<(usize, usize)>
Expand description

Finds the range of text between the specified start and end delimiters.

§Arguments

  • text - The input string from which to find the range.
  • start_delimiter - The delimiter that marks the beginning of the range.
  • end_delimiter - The delimiter that marks the end of the range.

§Returns

An Option<(usize, usize)> containing a tuple with the start and end indices of the range if both delimiters are found in the input string, or None if either delimiter is not found.

§Examples


use rust_string_utils::find_range_between_delimiters;
let result = find_range_between_delimiters("hello world!", "hello ", "!");
assert_eq!(result, Some((6, 10)));