df <- data.frame(
videos = c("Moon vs Grubby", "Moon vs Happy", "Happy vs Th00"),
links = c("https://www.youtube.com/watch?v=QlNc-jb4ESk&t", "https://www.youtube.com/watch?v=VESO8YQVFSE", "https://www.youtube.com/watch?v=RI3IJT8ZzBM")
)
df$links <- as.character(df$links)
df$links <- gsub("watch?v=", "embed/", df$links)
I have got the following code with links to YouTube which I want to embed in a shiny App. However YouTube needs to replace part of the string which is interpreted as a regular expression. I did not find a helpful solution here.
So how can I gsub
this pattern?
Current Links:
https://www.youtube.com/watch?v=QlNc-jb4ESk&t
Expected Outcome:
https://www.youtube.com/embed/=QlNc-jb4ESk&t