Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/435.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
在Javascript中搜索文本中的模式_Javascript_Angularjs_Ionic Framework - Fatal编程技术网

在Javascript中搜索文本中的模式

在Javascript中搜索文本中的模式,javascript,angularjs,ionic-framework,Javascript,Angularjs,Ionic Framework,我想用空格替换一些遵循某种模式的单词,例如-(:smile:)或(:riya:)或可能是(:money:)的单词,也就是说,每当我找到“(:”和“:)”时,它就会被空格替换 例如: This is a demo text (:ritu:) to demonstrate (:money:) what is the problem. 结果: This is a demo text to demonstrate what is the problem. 如何使用javascript实现这一点?使用

我想用空格替换一些遵循某种模式的单词,例如-(:smile:)或(:riya:)或可能是(:money:)的单词,也就是说,每当我找到“(:”和“:)”时,它就会被空格替换

例如:

This is a demo text (:ritu:) to demonstrate (:money:) what is the problem.
结果:

This is a demo text to demonstrate what is the problem.

如何使用javascript实现这一点?

使用
str.replace

var str='这是一个演示文本(:ritu:)来演示(:money:)问题出在哪里。'
警报(str.replace(/\s?\(:.*?:\)/g',)