YARQ(另一个正则表达式问题)。
我该如何将以下内容拆分为两列,确保最后一列包含句子中的最后一个单词,而第一列包含其他所有内容。
x <- c("This is a test",
"Testing 1,2,3 Hello",
"Foo Bar",
"Random 214274(%*(^(* Sample",
"Some Hyphenated-Thing"
)
以至于我最终得到:
col1 col2
this is a test
Testing 1,2,3 Hello
Foo Bar
Random 214274(%*(^(* Sample
Some Hyphenated-Thing
\\w\\d
。你最好用\\S
替换那部分:任何非空格字符。 - Marius