相关疑难解决方法(0)

在字符串中搜索unicode值

我试图在由字符串组成的数据框中标识唯一的unicode值。我尝试使用grep函数,但是遇到以下错误

Error: '\U' used without hex digits in character string starting ""\U"
Run Code Online (Sandbox Code Playgroud)

数据框示例

                     time sender                                                    message
1     2012-12-04 13:40:00      1                                            Hello handsome!
2     2012-12-04 13:40:08      1                                                 \U0001f618
3     2012-12-04 14:39:24      1                                                 \U0001f603
4     2012-12-04 16:04:25      2                                            <image omitted>
73    2012-12-05 06:02:17      1 Haha not white and blue... White with blue eyes \U0001f61c
40619 2015-05-08 10:00:58      1                                       \U0001f631\U0001f637

grep("\U", dat$messages)
Run Code Online (Sandbox Code Playgroud)

数据

dat <- 
structure(list(time = c("2012-12-04 13:40:00", "2012-12-04 13:40:08", 
"2012-12-04 14:39:24", "2012-12-04 16:04:25", "2012-12-05 06:02:17", 
"2015-05-08 10:00:58"), sender = c(1L, 1L, …
Run Code Online (Sandbox Code Playgroud)

unicode grep r gsub

3
推荐指数
2
解决办法
1412
查看次数

标签 统计

grep ×1

gsub ×1

r ×1

unicode ×1