ruby - 使用正则表达式删除 "..."之后的所有内容

标签 ruby regex

我有这样一个字符串:

"Product DescriptionThe Signature Series treatment makes the strategy guide a COLLECTIBLE ITEM for StarCraft II fans. Single-player CAMPAIGN WALKTHROUGH covers all possible mission branches, including bonus objectives throughout the campaign. Exclusive MAPS found only in the official guide, show locations of units,... \n\n\n\n\n\n\nRead More\n"

如何使用正则表达式 .text[/(...)/] 删除 ... 之后的内容,以便输出如下所示?

"Product DescriptionThe Signature Series treatment makes the strategy guide a COLLECTIBLE ITEM for StarCraft II fans. Single-player CAMPAIGN WALKTHROUGH covers all possible mission branches, including bonus objectives throughout the campaign. Exclusive MAPS found only in the official guide, show locations of units,..."

最佳答案

你需要避开那个时期。

string.sub(/(?<=\.\.\.).*/m, "")

string[/.*\.\.\./m]

关于ruby - 使用正则表达式删除 "..."之后的所有内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18508492/

相关文章:

ruby - 从字符串中删除所有非西里尔符号

Ruby:总结特定日期之间哈希数组中的值

javascript - 无法替换 JavaScript 中的 ↵ 符号?

php - 提取图像路径

javascript - 正则表达式查找最后一个空格字符

ruby - 为什么以及何时使用 shell 而不是 Ruby

ruby - $: in Ruby 是什么意思

javascript - 使用 RegEx 清除 HTML 中的空格

regex - 为什么带有 perl 正则表达式的 git-log 负向后查找会导致 fatal error ?

ruby-on-rails - 嵌套资源 Rails 4.1 路由中的单个自定义参数名称