gpt4 book ai didi

regex - 使用模式分割字符串

转载 作者:行者123 更新时间:2023-12-02 00:41:54 26 4
gpt4 key购买 nike

初始向量为

"WhiteRiver"   "microProcess" "PartsUnknown" "RedSox"

如何将其拆分为

White"   "River"   "micro"   "Process" "Parts"   "Unknown" "Red"  "Sox"

规则是区分大小写。

最佳答案

如果v1是向量

unlist(strsplit(v1, "(?<=[a-z])(?=[A-Z])", perl=TRUE))
#[1] "White" "River" "micro" "Process" "Parts" "Unknown" "Red"
#[8] "Sox"

(?<=[a-z])向后查找小写字母

(?=[A-Z])向前查找大写字母

关于regex - 使用模式分割字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25236454/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com