regex - Length of location sequence (given as a string) in R -


i have list of geolocation sequences. each element of list of form :

> "[[1.2,2.2],[-1.12,3.45],[12.311,-1.34],[-12.32,33.333]]" 

i able length of sequence (4 in example above). please me? i've tried use regular expressions couldn't succeed.

thank in advance!

as few folks suggested in comments, can count # of times specific character appears in sequences. assumes data formed , consistent. example:

library(stringr) x <- "[[1.2,2.2],[-1.12,3.45],[12.311,-1.34],[-12.32,33.333]]" str_count(x, "\\[") - 1 #subtract 1 since there 2 opening [ 

yields:

> str_count(x, "\\[") - 1 [1] 4