如何删除特定单词后的文本

发布于 2024-12-04 04:28:23 字数 138 浏览 0 评论 0原文

我有一个字符串

The best laid schemes of mice and men

如何删除 ColdFusion 中“schemes”一词后面的所有文本?我想这可以用正则表达式来完成。

I have a string

The best laid schemes of mice and men

How do I remove all text after the word "schemes" in ColdFusion? I suppose this can be done with regex.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

怕倦 2024-12-11 04:28:23

给你:

<cfset myString = "The best laid schemes of mice and men" />
<cfoutput>#REReplace(myString, "schemes(.*)", "schemes")#</cfoutput>

Here ya go:

<cfset myString = "The best laid schemes of mice and men" />
<cfoutput>#REReplace(myString, "schemes(.*)", "schemes")#</cfoutput>
心凉 2024-12-11 04:28:23

您的正则表达式是:

schemes.*$

并替换为“schemes”

解释

.*$ 表示匹配任何字符 (.) 0 次或多次 (*) 直到行尾 ($)

Your regex is:

schemes.*$

and replace with "schemes"

Explanation

.*$ means match any character (.) 0 or more times (*) till the end of the row ($)

若有似无的小暗淡 2024-12-11 04:28:23

尝试这个正则表达式:

schemes(.*)

将 $1 替换为空字符串“”

Try this regex:

schemes(.*)

Replace $1 with empty string ""

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文