R regular expression

backslash, r, regex

Solution

> testSampe <- "Old:windows\r\nNew:linux\r\n"
> gsub(":[^\r\n]*", "", testSampe)
[1] "Old\r\nNew\r\n"

Problem

I have a string like below. ``` testSampe <- "Old:windows\r\nNew:linux\r\n" ``` I want to erase the string between `":"` an `"\"`. Like this `"Old\r\nNew\r\n"`. How can I construct the regex for this? I tried to gsub function with regex `":.*\\\\"`, It doesn't work. ``` gsub(":.*\\\\", "\\\\r", testSampe) ```

Original source