Ugly indeed
d = """@christophergandrud, C. Jason Liang, Clay Ford, @cornelius1729, @cplouffe, Craig Citro, @crossfitAL, @crowding, @crtahlin, Crt Ahlin, @cscheid, @csgillespie, @cusanovich, @cwarden, @cwickham, Daniel Lee, @darrkj, @Dasonk, David Hajage, David LeBauer, @dchudz, dennis feehan, @dfeehan, Dirk Eddelbuettel, @dkahle, @dlebauer, @dlschweizer, @dmontaner, @dougmitarotonda, @dpatschke, @duncandonutz, @EdFineOKL, @EDiLD, @eipi10, @elegrand, @EmilRehnberg, Eric C. Anderson, @etb, @fabian-s, Facundo Muñoz, @flammy0530"""
print( unlist(strsplit(d,", "))[ grep( "^@",unlist(strsplit(d,", ") )) ] )
or
d2 = unlist(strsplit(d,", ")
print( d2[ grep( "^@",d2 )) ] )
[1] "@christophergandrud" "@cornelius1729" "@cplouffe"
[4] "@crossfitAL" "@crowding" "@crtahlin"
[7] "@cscheid" "@csgillespie" "@cusanovich"
[10] "@cwarden" "@cwickham" "@darrkj"
[13] "@Dasonk" "@dchudz" "@dfeehan"
[16] "@dkahle" "@dlebauer" "@dlschweizer"
[19] "@dmontaner" "@dougmitarotonda" "@dpatschke"
[22] "@duncandonutz" "@EdFineOKL" "@EDiLD"
[25] "@eipi10" "@elegrand" "@EmilRehnberg"
[28] "@etb" "@fabian-s" "@flammy0530"
Pythonish....
print([ i for i in d.split(", ") if i.startswith("@") ])
['@christophergandrud', '@cornelius1729', '@cplouffe', '@crossfitAL', '@crowding', '@crtahlin', '@cscheid', '@csgillespie', '@cusanovich', '@cwarden', '@cwickham', '@darrkj', '@Dasonk', '@dchudz', '@dfeehan', '@dkahle', '@dlebauer', '@dlschweizer', '@dmontaner', '@dougmitarotonda', '@dpatschke', '@duncandonutz', '@EdFineOKL', '@EDiLD', '@eipi10', '@elegrand', '@EmilRehnberg', '@etb', '@fabian-s', '@flammy0530']
No comments:
Post a Comment