I need a way to split a string every n letters.
For example, let s="QW%ERT%ZU%I%O%P" and n=3, I want to obtain "QW%E" "RT%Z" "U%I%O" "%P".
As you can see, the special character "%" is not considered in the division.
I tried with
strsplit(s, "(?<=.{10})(?=.*\\%)", perl = TRUE)[[1]]
but I cannot find a way to obtain what I want.
What about
regmatches(instead ofstrsplit) like below?Or
tapply+strsplitwhich gives