Skip to contents

Get line numbers for pairs of regex matches

Usage

get_matching_line_numbers(x, regexes, silent = bookmark::opts$get("silent"))

Arguments

x

A character vector in which to look

regexes

A vector of two regular expressions, for example, for the default bookmark data, bookmark::opts$get("bm_start_chunk_regex") and bookmark::opts$get("bm_end_chunk_regex").

silent

Whether to be silent or chatty

Value

A list of 2-element vectors, with the first and last lines.

Examples

bookmark::get_matching_line_numbers(
  c(
    "Some text",
    "",
    "<!--[BOOKMARK-START::YAML::lg2_1]",
    "type: Learning Goal",
    "content: >",
    "  This is some content",
    "spread out over multiple lines.",
    "[BOOKMARK-END]-->",
    "",
    "Some more text"
  ),
  regexes = c(
    bookmark::opts$get("bm_start_chunk_regex"),
    bookmark::opts$get("bm_end_chunk_regex")
  )
);
#> [[1]]
#> [1] 3 8
#>