首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >删除字符串中特定开头的单词

删除字符串中特定开头的单词
EN

Stack Overflow用户
提问于 2014-09-23 14:18:01
回答 1查看 31关注 0票数 0
代码语言:javascript
复制
$string = '@English is a West Germanic @language that was first spoken in early medieval @England and is now a global lingua franca. @It is spoken as a first language by the';

我如何删除以“在一个动作中”开头的所有单词?

链接str_replace()的东西呢?

代码语言:javascript
复制
`$result = 'is a West Germanic that was first spoken in early medieval and is now a global lingua franca. is spoken as a first language by the'`;
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-09-23 14:35:27

给你:

代码语言:javascript
复制
echo $string | sed -e 's/@\w*//g'

这将与regex @\w*匹配的所有子字符串替换为空字符串。G标志确保匹配多个字符串。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25997486

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档