fixtags <- function(page)
{
   langs <- c("c", "c-sharp", "r")   
   langs <- paste(langs, collapse="|")
   page <- gsub(paste("<(", langs, ")>", sep=""), "<lang \\1>", page)
   page <- gsub(paste("</(", langs, ")>", sep=""), "</
   page <- gsub(paste("<code(", langs, ")>", sep=""), "<lang \\1>", page)
   page <- gsub(paste("</code>", sep=""), "</
   page
}

page <- "lorem ipsum <c>some c code</c>dolor sit amet,<c-sharp>some c-sharp code</c-sharp>
consectetur adipisicing elit,<code r>some r code</code>sed do eiusmod tempor incididunt"
fixtags(page)