“'\w' 是一个无法识别的转义符";在 grep [英] "'\w' is an unrecognized escape" in grep

查看:55
本文介绍了“'\w' 是一个无法识别的转义符";在 grep的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 R 中的某些项目中使用 grep(使用 perl=TRUE 标志),并且在我的一生中我无法弄清楚为什么 R 不断抛出错误.我的查询如下:

I'm using grep in some projects in R (which uses a perl=TRUE flag) and for the life of me I can't figure out why R keeps throwing errors. My query is as follows:

d$SomeColumn[grep("(?ix)<VNW[^;]*;(dis|dat)> \w*<N\(", d$Right, perl=TRUE)] <- 1

然而,R 抛出以下错误:

However, R throws the following error:

Error: '\w' is an unrecognized escape in character string starting ""<VNW[^;]*;(dis|dat)> \w"

推荐答案

您需要在 r 中再次转义反斜杠.

You need to escape the backslashes one more time in r.

d$SomeColumn[grep("(?ix)<VNW[^;]*;(dis|dat)> \\w*<N\\(", d$Right, perl=TRUE)] <- 1

                                              |     |

这篇关于“'\w' 是一个无法识别的转义符";在 grep的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆