Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.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_Regex_String - Fatal编程技术网

Javascript {}内所有单词和符号的正则表达式模式

Javascript {}内所有单词和符号的正则表达式模式,javascript,regex,string,Javascript,Regex,String,我有这个输入字符串 ~{RegExr1234124124.} was ~{created by gskinner.com}, and is ~{proudly hosted} by Media Temple. 并希望得到以下输出: was, and is by Media Template 我使用了/~{.*}+/gregex模式,但它是错误的原因是*匹配字符串中{之后的所有字符 使用/~{[^}]+}/匹配~{}中的每个字符串,然后使用.replace()删除它们 var str=“{r

我有这个输入字符串

~{RegExr1234124124.} was ~{created by gskinner.com}, and is ~{proudly hosted} by Media Temple.
并希望得到以下输出:

was, and is by Media Template

我使用了
/~{.*}+/g
regex模式,但它是错误的

原因是
*
匹配字符串中
{
之后的所有字符

使用
/~{[^}]+}/
匹配
~{}
中的每个字符串,然后使用
.replace()
删除它们

var str=“{regexr123412424.}是{由gskinner.com创建的},是{由Media Temple自豪地托管的}”;

log(str.replace(/~{[^}]+}/g',).trim()发布的问题似乎根本不包含解决问题的方法。StackOverflow希望您能这样做,因为您的尝试有助于我们更好地了解您的需求。请编辑问题以显示您已尝试的内容,以便说明您遇到的具体障碍。有关更多信息,请参阅并使用.Use
str.replace(/~{[^}]+}/g')
var newStr = str.replace(/~{[^}]+}/g, '');