Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 将感叹号替换为正则表达式可变时间_Regex_Erlang - Fatal编程技术网

Regex 将感叹号替换为正则表达式可变时间

Regex 将感叹号替换为正则表达式可变时间,regex,erlang,Regex,Erlang,我需要替换句子中的所有感叹号,我可以为第一个感叹号替换感叹号,但我不知道如何在不循环的情况下对随机字符串中的所有单词/空格重复感叹号 Sentence = "! word! hello cat! you are !! the one" regex:replace(Sentence, "!", "" ); 这个返回单词!你好,猫!你是!!那个。 那么,这不需要循环就能实现吗?这里有一个正式的答案,将其从评论中删除 只需在正则表达式替换例程中使用全局修饰符: Sentence = "! word!

我需要替换句子中的所有感叹号,我可以为第一个感叹号替换感叹号,但我不知道如何在不循环的情况下对随机字符串中的所有单词/空格重复感叹号

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])
这里有一个正式的答案,将其从评论中删除

只需在正则表达式替换例程中使用全局修饰符:

Sentence = "! word! hello cat! you are !! the one"
re:replace(Sentence, "!", "", [global, {return, list}, unicode])

您使用的是哪种语言?无论您使用哪种语言,都应该有一个全局替换运算符。在Perl中,它看起来像s///最后的g表示替换所有匹配项。嗨,我正在使用Erlang。我将查找全局替换字符。谢谢!约拿,问题解决了。Erlang允许您添加全局选项,现在它可以工作了。所以re:替换!单词你好,猫!你是!!那个!,[全局,{return,list},unicode]。返回单词hello cat你就是那个人。谢谢。如果您解决了自己的问题,请将您的解决方案作为答案发布并接受。您使用的是哪种语言?无论您使用哪种语言,都应该有一个全局替换运算符。在Perl中,它看起来像s///最后的g表示替换所有匹配项。嗨,我正在使用Erlang。我将查找全局替换字符。谢谢!约拿,问题解决了。Erlang允许您添加全局选项,现在它可以工作了。所以re:替换!单词你好,猫!你是!!那个!,[全局,{return,list},unicode]。返回单词hello cat你就是那个人。谢谢。如果您解决了自己的问题,请将您的解决方案作为答案发布并接受。