I have a string (fasta format), something like this:
a = ">atttaggacctta\nattgtcggta\n>ccattnnnn\ncccatt\n>ttaggccta"
and would like to seperate at character >
, filter out the newlines and put the thre substrings seperated by >
into a vector or list with three elements:
>atttaggaccttaattgtcggta
>ccattnnnncccatt
>ttaggccta
I tried strsplit
:
unlist(strsplit(a, "(?<=>)", perl=T))
but this puts the delimiter >
at the end of the each string.
I found related questions are here or here but I can't really get it to work without making a complicated construct.
Is there a simple solution to do this in one go?