Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要替换句子中的所有感叹号,我可以为第一个感叹号做到这一点,但我不明白如何让它重复随机字符串中的所有单词/空格而不循环。
Sentence = "! word! hello cat! you are !! the one" regex:replace(Sentence, "!", "" );
这将返回“单词!你好猫!你是!!那个”。那么这可能没有循环吗?
这是一个正式的答案(将其从评论中移出)。
只需在正则表达式替换例程中使用全局修饰符:
Sentence = "! word! hello cat! you are !! the one" re:replace(Sentence, "!", "", [global, {return, list}, unicode])