Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace string gsub in R

how do i parse this string in R so that it will look like the following? I'm trying to do this through regular expression through gsub(), but not getting any luck

Input:

"dag{D<-{G}; A<-{D}; A<-{G}; A<-{Q}}"

Output:

"D<-G;A<-D;A<-G;A<-Q"

I've tried:

gsub("dag{(.*)}","","dag{D<-{G}; A<-{D}; A<-{G}; A<-{Q}}")

like image 829
Eisen Avatar asked Jul 24 '26 16:07

Eisen


1 Answers

Is this good for you ?

gsub(pattern = "dag|\\{|\\}|[[:space:]]", replacement = "", x = "dag{D<-{G}; A<-{D}; A<-{G}; A<-{Q}}")
like image 153
DataM Avatar answered Jul 26 '26 08:07

DataM