查找双引号中的所有数字并删除双引号

时间:2022-09-15 13:37:12

I've accidentally formatted a huge file incorrectly. I have several hundred vars defined as:

我不小心格式化了一个大文件。我有几百个vars定义为:

"exportOrder": "274"

When I really need:

当我真的需要:

"exportOrder": 274

Anyone know a regex to remove the double quotes in each of these occurrences?

谁知道一个正则表达式来删除每一个事件中的双引号?

The sample data looks like so:

样本数据如下:

{
    "key": "date",
    "name": "Date",
    "datatype": "date",
    "exportOrder": "274"
},
{
    "key": "coordinates",
    "name": "Coordinates",
    "datatype": "geoPoint",
    "exportOrder": "275"
},

and so on..

等等. .

I can remove the first quote with: :%s/Order": "/Order": /g

我可以删除第一个报价:%s/Order": "/Order": /g

but can't figure out the 2nd quote.

但是不能算出第二个报价。

Thanks

谢谢

1 个解决方案

#1


2  

You can use this:

您可以使用:

:%s/"\([0-9]\+\)"/\1/g

I'm capturing the number within the quotes in capturing group one.

我在捕获第一组的引号内捕捉到数字。

#1


2  

You can use this:

您可以使用:

:%s/"\([0-9]\+\)"/\1/g

I'm capturing the number within the quotes in capturing group one.

我在捕获第一组的引号内捕捉到数字。