I would like to replace every _
with a -
on lines starting with #| label:
using PCRE2 regex within my text editor.
Example:
#| label: my_chunk_label
my_function_name <- function(x)
Should become:
#| label: my-chunk-label
my_function_name <- function(x)
In contrast to .NET regex, where one could substitute (?<=^#\| label: .+)_
with -
(regex101 example), PCRE2 does not support infinite lookbehind so the regex is invalid. So far, the only way I found was to repeatedly substitute ^#[^_]+\K_
with -
(regex101 example) but I was curious if there is a single-pass solution.