How to use regex to capture line break in Find and Replace feature of RStudio?

Hello, happy new year!

I have these code from an LLM:

R

```

I want to turn it into

```{r}

I tried Find R\n\s``` and replace ```{r}, it works in Zed, but it does not in RStudio.

What is the acceptable syntax?

Thank you!

AFAIK you cannot do this with the search and replace function in the RStudio editor, (it does work in Positron) but you could use a regex to replace text in the c/p buffer with

clipr::write_clip(
  gsub(
    "R\n```", 
    "```{r}", 
    paste(
      clipr::read_clip(), 
      collapse = "\n")
    )
  )

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.