Javascript正则表达式从字符串中删除字符和数字

Javascript正则表达式从字符串中删除字符和数字,javascript,regex,string,replace,Javascript,Regex,String,Replace,我有一个字符串,我需要从包含它们的所有单词中删除下划线数字 "View":{"Name":"Untitled-4","Image_1":{"BackgroundImage":"Image.png","Position":[0,0],"Width":320,"Height":480},"Button_1":{"BackgroundImage":"ButtonTop.png","Position":[61,83],"Width":217,"Height":58},"Button_2":{"Backg

我有一个字符串,我需要从包含它们的所有单词中删除下划线数字

"View":{"Name":"Untitled-4","Image_1":{"BackgroundImage":"Image.png","Position":[0,0],"Width":320,"Height":480},"Button_1":{"BackgroundImage":"ButtonTop.png","Position":[61,83],"Width":217,"Height":58},"Button_2":{"BackgroundImage":"ButtonBottom.png","Position":[81,114],"Width":205,"Height":73},"TextField_1":{"BackgroundImage":"TextFieldLogin.png","Position":[102,336],"Width":189,"Height":31},"Label_1":{"Position":[137,100],"Width":54,"Height":20,"Text":"HiRob","FontSize":18,"Color":[0,0,0,1]},"Label_2":{"Position":[43,342],"Width":72,"Height":20,"Text":"LogOut:","FontSize":18,"Color":[0,0,0,1]},"Label_3":{"Position":[115,234],"Width":126,"Height":20,"Text":"AnotherButton","FontSize":18,"Color":[0,0,0,1]}}
我要寻找的输出是:

"View":{"Name":"Untitled-4","Image":{"BackgroundImage":"Image.png","Position":[0,0],"Width":320,"Height":480},"Button":{"BackgroundImage":"ButtonTop.png","Position":[61,83],"Width":217,"Height":58},"Button":{"BackgroundImage":"ButtonBottom.png","Position":[81,114],"Width":205,"Height":73},"TextField":{"BackgroundImage":"TextFieldLogin.png","Position":[102,336],"Width":189,"Height":31},"Label":{"Position":[137,100],"Width":54,"Height":20,"Text":"HiRob","FontSize":18,"Color":[0,0,0,1]},"Label":{"Position":[43,342],"Width":72,"Height":20,"Text":"LogOut:","FontSize":18,"Color":[0,0,0,1]},"Label":{"Position":[115,234],"Width":126,"Height":20,"Text":"AnotherButton","FontSize":18,"Color":[0,0,0,1]}}
你能行

var replaced = str.replace(/_\d+/g, '')

这看起来太像JSON了。你确定不想只在键上应用删除吗?它不仅看起来像JSON,而且应用的转换会将其转换为非法JSON(JSON对象不能有重复的键,请参见RFC 4627)。这在下面得到了解决,但我们在上面使用编号的原因是为了在用作JSON时保持其唯一性,然后,当它作为字符串存储在数据库中时,我们去掉了编号。由于其他一些依赖性,我们无法以任何其他方式对其进行结构化。