[英]Split string by comma but not comma within number R
I have a string that looks like:我有一个看起来像的字符串:
a <- "900, 1,100, 1000"
I want to split the string by commas that are not within a number to obtain:我想用不在数字内的逗号分割字符串以获得:
"900" "1,100" "1000"
I can split using all the commas b <- strsplit(a, ',')
however this gives me the output "900" "1" "100" "1000"
which I don't want.我可以使用所有逗号
b <- strsplit(a, ',')
进行拆分b <- strsplit(a, ',')
但是这给了我不想要的输出"900" "1" "100" "1000"
。
好吧,如果您在模式中包含空格,这应该很容易:
b <- strsplit(a, ', ')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.