假设我使用下面的字符串:
x <- "County January 2016 February 2016 March 2016 April 2016 May 2016 June 2016 July 2016 August 2016 September 2016 October 2016 November 2016 December 2016\r"
通过运行以下两个命令我收集到的是'\ s'将寻找''(空格)以及'\'反斜杠。
strsplit(x, "(?<=2016) +", perl=T)
[[1]]
[1] "County January 2016"
[2] "February 2016"
[3] "March 2016"
[4] "April 2016"
[5] "May 2016"
[6] "June 2016"
[7] "July 2016"
[8] "August 2016"
[9] "September 2016"
[10] "October 2016"
[11] "November 2016"
[12] "December 2016\r"
strsplit(x, "(?<=2016)\\s+", perl=T)
[[1]]
[1] "County January 2016"
[2] "February 2016"
[3] "March 2016"
[4] "April 2016"
[5] "May 2016"
[6] "June 2016"
[7] "July 2016"
[8] "August 2016"
[9] "September 2016"
[10] "October 2016"
[11] "November 2016"
[12] "December 2016"
由于第二个命令在2016年之后也分裂为'\'。我理解这是正确的吗?感谢帮助谢谢。