在R,正則表達式匹配反斜線
我有以下字符串:C:\\Users\\jam\\Downloads\\tomato\\roja.exe
及以下的正則表達式:^(.*\\\\)([^\\\\]*)$
從此我想要的文件夾路徑:C:\\Users\\jam\\Downloads\\tomato\\
如果我這樣做grep像:
grep("^(.*\\\\)([^\\\\]*)$", "C:\\Users\\jam\\Downloads\\tomato\\roja.exe",value=TRUE)
我得到C:\\Users\\jam\\Downloads\\tomato\\roja.exe
結果是不是預期的結果。
關於提高正則表達式的任何想法?
剛剛'^(。* \\\\)' – MElliott
@MElliott nope不能正常工作 – umbersar