r 在数字之间加入单词
r join words if in between numbers
a <- c("it is ZZ10 AS 1234 and ZZ10 ASD 123")
如果字母数字和数字之间只有 2 个字母,我如何连接单词
预期输出
"it is ZZ10AS1234 and ZZ10 ASD 123"
如果单词只有 2 个字母并且介于字母数字和数字之间,您可以加入单词:
gsub("([[:alnum:]]) (\w\w) (\d)", "\1\2\3", a)
#[1] "it is ZZ10AS1234 and ZZ10 ASD 123"
a <- c("it is ZZ10 AS 1234 and ZZ10 ASD 123")
如果字母数字和数字之间只有 2 个字母,我如何连接单词
预期输出
"it is ZZ10AS1234 and ZZ10 ASD 123"
如果单词只有 2 个字母并且介于字母数字和数字之间,您可以加入单词:
gsub("([[:alnum:]]) (\w\w) (\d)", "\1\2\3", a)
#[1] "it is ZZ10AS1234 and ZZ10 ASD 123"