I need to recognize a regular expression and its sub-variations and paste all expressions in one line divided by a pipe symbol.
## I have this vector:
teste<- as.vector(c("MG_00001_01", "MG_00001_02",
"MG_00002_01","MG_00002_02", "MG_00002_03",
"MG_00003_01","MG_00003_02"))
> teste
[1] "MG_00001_01" "MG_00001_02" "MG_00002_01" "MG_00002_02" "MG_00002_03" "MG_00003_01" "MG_00003_02"`
## and I need a data frame with every sub-variations of a regular expression in
## single row and separated by a pipe # symbol, like this:
> result
1 "MG_00001_01"|"MG_00001_02"
2 "MG_00002_01"|"MG_00002_02"|"MG_00002_03"
3 "MG_00003_01"|"MG_00003_02"