Search for a backslash in a string obtained from an external source

I have a row that I received from my DB, so in R it looks like this:

a <- c("www", "x", "yes", "\303\243")

> a
[1] "www" "x"   "yes" "ã" 

What I want to do is find which of the elements has a backslash in it. I tried:

grepl('\\',a[4])

But I keep getting the error

invalid regular expression '\', reason for "Trailing backslash"

regardless of whether i use cator fixed=T.

How to find backslash in a list?

+4
source share
1 answer

, R . grepl("\\", a[4]) \, grepl("\\\\", a[4]) \\. cat("\\").

, , escape-, .

0

Source: https://habr.com/ru/post/1612195/


All Articles