【问题标题】:Regex in sublime text is not efficient崇高文本中的正则表达式效率不高
【发布时间】:2015-11-28 12:14:15
【问题描述】:

我想使用 sublime 在我的 json 中查找和删除“indicent”对象。这是正则表达式

\s*+,\s*(.)+"\s*indices+"\s*:\s*+(.)\s*\s*(.)+\s*(.)+\s*+]

但是,它的堆栈空间用完了。我认为正则表达式效率不高。

json 示例:

           "created": "Fri Nov 27 11:12:43 +0000 2015",
            "text": "https://t.co/8r5dQ7zRYG #johnl3375 Kim Gi Jung",
            "source": "NOMOR1",
            "hashtags": [
                {
                    "text": "johnl3375",
                    "indices": [
                        24,
                        34
                    ]
                }
            ],
            "url": [
                {
                    "url": "https://t.co/8r5dQ7zRYG",
                    "expanded_url": "https://play.google.com/store/apps/details?id=com.aturkeuangan.nomor1#refid=johnl3375",
                    "display_url": "play.google.com/store/apps/det…",
                    "indices": [
                        0,
                        23
                    ]
                }
            ]

我想要这样的json

            "created": "Fri Nov 27 11:12:43 +0000 2015",
            "text": "https://t.co/8r5dQ7zRYG #johnl3375 Kim Gi Jung",
            "source": "NOMOR1",
            "hashtags": [
                {
                    "text": "johnl3375"
                }
            ],
            "url": [
                {
                    "url": "https://t.co/8r5dQ7zRYG",
                    "expanded_url": "https://play.google.com/store/apps/details?id=com.aturkeuangan.nomor1#refid=johnl3375",
                    "display_url": "play.google.com/store/apps/det…"
                }
            ]

我的正则表达式应该是什么?

【问题讨论】:

    标签: json regex sublimetext3


    【解决方案1】:

    这适用于我在 ST3 中使用您的 JSON 示例:[\s,]+"indices":[^]]+]

    【讨论】:

      猜你喜欢
      • 2014-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-22
      • 1970-01-01
      • 1970-01-01
      • 2017-10-31
      • 1970-01-01
      相关资源
      最近更新 更多