I am looking to replace all *s at the end of a string, in R.
txt <- c("arm","foot-ha-*","lefroo", "bafoobar*")
gsub("/\\*$/","",txt, perl=TRUE);
I would like to convert txt to be "arm" "foo-ha-" "lefroo" "bafoobar"
What am I doing wrong?
Thanks!
您在正则表达式中不需要/
。
gsub("\\\\*$", "", txt)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.