问题描述
假设我有一个字符串表:
df <-tibble::tribble(
~ alternatives," 23.32 | x232 code | This is a description| 43.11 | a341 code | some other description | optimised | v333 code | still another description" )
我想在数值前面的位置拆分字符串:例如。 23.32 之前,43.11 之前,以及“优化”这个词之前。
期望我在每个单元格中实现向量:
c(23.32 | x232 code | This is a description|,43.11 | a341 code | some other description |,optimised | v333 code | still another description)
在特定模式之前实现拆分的正则表达式模式应该是什么?有关模式之间的管道字符数可能不同,我无法可靠地使用它们。我隐约知道前瞻等。此代码不会返回我期望的内容,但我相信我正在寻找类似的解决方案(这不会做我想要的):
df2 <-
df %>%
mutate(alternatives =
str_split(alternatives,pattern = "(?<=[a-zA-Z])\\s*(?=[0-9])"))
enter code here
解决方案是什么?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)