0

I apologize for possible similar questions, but I just can't find the solution for my problem. So, I have a string with three parts, separated by “.”, for example:

a <- "XXX.YY.ZZZ"

(the length of strings differ, it could also be a <- "XXXX.Y.ZZ", but the three parts are always separated by the two “.”. I solved the problem for the first part:

library(stringi)
stri_extract(a, regex='[^.]*')
[1] "XXX"

Appreciate your help.

JerryTheForester
  • 456
  • 1
  • 9
  • 26

1 Answers1

1

hello you can use strsplit as follows

   strsplit(a,"\\.")[[1]] 
Beginner
  • 262
  • 1
  • 4
  • 12