R正则表达式删除除撇号之外的所有标点符号
发布时间:2020-12-14 06:31:05 所属栏目:百科 来源:网络整理
导读:参见英文答案 Remove all punctuation except apostrophes in R4个 我试图从除撇号之外的字符串中删除所有标点符号.这是我的exastr2 - str2 - "this doesn't not have an apostrophe,.!@#$%^*()"gsub("[[:punct:,^']]"," ",str2 )# [1] "this doesn't not
参见英文答案 >
Remove all punctuation except apostrophes in R4个
我试图从除撇号之外的字符串中删除所有标点符号.这是我的exastr2< - str2 <- "this doesn't not have an apostrophe,.!@#$%^&*()" gsub("[[:punct:,^']]"," ",str2 ) # [1] "this doesn't not have an apostrophe,.!@#$%^&*()" 我究竟做错了什么?
在使用标点符号进行测试之前,可以使用“否定先行断言”来删除任何撇号.
gsub("(?!')[[:punct:]]","",str2,perl=TRUE) # [1] "this doesn't not have an apostrophe" (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |