删除字符串中句点前的所有字符 [英] Remove all characters before a period in a string

查看:56
本文介绍了删除字符串中句点前的所有字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这会保留一段时间之前的所有内容:

This keeps everything before a period:

gsub("\\..*","", data$column )

经期过后如何保留一切?

how to keep everything after the period?

推荐答案

删除字符串中句点前的所有字符(包括句点).

To remove all the characters before a period in a string(including period).

gsub("^.*\\.","", data$column )

示例:

> data <- 'foobar.barfoo'
> gsub("^.*\\.","", data)
[1] "barfoo"

删除第一个句点之前的所有字符(包括句点).

To remove all the characters before the first period(including period).

> data <- 'foo.bar.barfoo'
> gsub("^.*?\\.","", data)
[1] "bar.barfoo"

这篇关于删除字符串中句点前的所有字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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