Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个字符串 'ABC1\001ABCEFCGJS' 我想从这个字符串中只提取 001ABCEFCGJS 如何在 R 中这样做?我的字符串将是一个动态字符串。所以解决方案应该是函数可以在反斜杠之后读取任何内容。
一种选择是转换为raw然后删除元素,同时为“001”附加正确的原始值
raw
rawToChar(c(charToRaw('001'),charToRaw(str1)[-(1:5)])) #[1] "001ABCEFCGJS"
str1 <- 'ABC1\001ABCEFCGJS'