gpt4 book ai didi

ruby - 我怎样才能巩固这个表达?

转载 作者:太空宇宙 更新时间:2023-11-03 17:17:02 24 4
gpt4 key购买 nike

我正在删除乐队名称的首字母“The”和空格,以便连接到 url 中。我有这个,但是它很难看,我想合并成一个表达式。

@artist.sub!(/[Tt]he/, '')
@artist.gsub!(/\s+/, '')

最佳答案

尝试:

@artist.gsub!(/(\A[Tt]he)|(\s+)/, '')

关于ruby - 我怎样才能巩固这个表达?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13781154/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com