1
s = "hi@hello"
strsplit(s,"@")[[1]]

my output result is "hi" "hello"

but i got the different result when using the "*" symbol.

s = "hi*hello"
strsplit(s,"*")[[1]]

output result is "h" "i" "" "h" "e" "l" "l" "o"*

May i know the strsplit function working different on the * and + symbol.

dondapati
  • 829
  • 6
  • 18

1 Answers1

1

We need fixed = TRUE as it is a metacharacter signifying zero or more characters. THe solution is to add fixed = TRUE or escape (\\*)

strsplit(s,"*", fixed= TRUE)[[1]]
akrun
  • 874,273
  • 37
  • 540
  • 662