0

In R, I have a character string w and would like to get rid of the SQL commented parts i.e. the characters between /* and */.

This is what I have tried so far, but it doesn't quite work....

 w <- "ldsjflsdj /* hhhhhhhhsdlfjlsj */ dskfhjsdkjfhsd"
 gsub("[/**/]","",w)

The ideal output would be something like:

`ldsjflsdj dskfhjsdkjfhsd`

How do I achieve this?

I am pretty sure it's simple I'm just not an expert in regex

Thanks,

HLM

4

2 に答える 2

2

qdapパッケージgenX:

library(qdap)
genX(w, "/\\*", "/\\*")

## [1] "ldsjflsdj dskfhjsdkjfhsd"
于 2013-07-16T11:12:27.760 に答える