//@john:awesome play @user2:great....//@user3:wow%oke"kakaa"
@user5:aha@user3:hello
@user6:helloow @user7:database @user1:ok
我想要的结果是用户,即" @"之间的单词/字符串;和":",我试图分裂
text_1 = strsplit(as.character(df$text), '(?<=[^@])(?=@)', perl=TRUE)
但结果不是我想要的 我希望结果如下所示
john user2 user3
user5 user3
user6 user7 user1
答案 0 :(得分:1)
如果string
是您的字符串,您可以尝试:
regmatches(gregexpr("(?<=@)[^:]+",string,perl=TRUE),x=string)[[1]]
#[1] "john" "user2" "user3" "user5" "user3" "user6" "user7" "user1"