找回密码
 加入
搜索
查看: 264|回复: 1

[AU3基础] 【已解决】请教一个正则修改json文件的问题

[复制链接]
发表于 2024-1-13 19:31:48 | 显示全部楼层 |阅读模式
本帖最后由 fybhwsx 于 2024-1-13 20:21 编辑

我想在最底下大括号上面添加两行:
  "flutter.ls_minimize_to_tray": true,
  "flutter.ls_quick_save": true



这个文件格式最底下的“}”上面一行最后没有“,”号,添加的时候原先最后一行文本要加“,”



用FileOpen和FileRead读到的原始文本如下:
{
  "flutter.ls_version": 1,
  "flutter.ls_show_token": "f6ccb2dd-4311-4754-96ad-01eb88bcf5ad",
  "flutter.ls_alias": "Great Lettuce",
  "flutter.ls_security_context": "{\"privateKey\":\"-----BEGIN RSA PRIVATE KEY-----\\nMIIEowIBAAKCAQEApVfrCIXuDnifR6UmobN06hu5/KOY5SGk3WDSF/h6ueMyMQPM\\nSbs646PcUT4SqPO6BeNOIIcIf5HPE2iD4HsxAcJrlBfmSIvS4uoue9sCzPFfhHa6\\n+tSyXEUkIEXEgzb8EQ1QCxzvV2tf6SYBOFO9Ondv7dtrHgiN2SQ45irmwv+Hp+CB\\nP1VWZe1l2exC3j35LR9WHelqjI5uIDmTGMCj0D1eBJG9Q+7Y/U6ujacLllsxgr3f\\nX7d+sg3IVJr9NE0wqd04Nb7yJGGygZ2NDjpGrPqGCcibt54Bx90INMqXWEwxvkTN\\nheLbIlNjs1m6UATaRl9D4yXfPXmTHPWASzBKhwIDAQABAoIBAQCPbU6SnCs/Hl98\\n9MQoLNXUZqzVfMyapq6u4tgctw0uxui5IARMST/yTChHyULCkHnjtaQGD1zN3Jv2\\nyAjt569BSXeshXbbo38SG/aqtfcd9JvY+m2EPJFj/Q4zeJHZCQ9rc1Ll8PmlqZ0P\\nUEpqpClX2Fedy2KGMQFrRUKeVsTKjR0H0+b6mauGMcT/T0iG6Nfhdkc5ycWEnAcS\\nSJhZvuyDGKs9WbJywNiV+8+FF4UeP3WCiy+3c0z6t2nL+Kkw7nwTM3UuvcfI6lAh\\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TCp3Tg1vvIkYbKBnY0OOkas+oYJyJu3ngHH3Qg0\\r\\nypdYTDG+RM2F4tsiU2OzWbpQBNpGX0PjJd89eZMc9YBLMEqHAgMBAAEwDQYJKoZI\\r\\nhvcNAQELBQADggEBAEWdRn2/MPRfGvq0NYNkXt0oa4Taqb7naipzFYrcGRsOeDS+\\r\\nFww1A1Rrr19YxFJQtAUqhoWx/C8VcW0GU4ClUssx7IFAipkEBjSr3WMut9m+N/7X\\r\\ngogbxuoh414LwMztHdNCurqZenS3H5tyRJPBmybrpzhgY9lSaej4z1Et4TsoIFZ9\\r\\nwzHTT+zJNV64KYFJbQUFKulQ2OEnW6mPhgr8OzAUAF2ABimtGvH7EiPaUrUImp7w\\r\\nRg6yb1jECBNUlj0kiAr19CZiEUDHhh15Ql9rNhJeaoU6XASzWdjnsdP3GQNuJBwA\\r\\n3bOYWvLK/9BW67p+a9OnMdz3qUpHAspwlax/eVQ=\\n-----END CERTIFICATE-----\",\"certificateHash\":\"BADC0ED5405CAE1D3AD9857A6DABBD35A363F9B593C58598195FFA066BFFD1FA\"}",
  "flutter.ls_color": "localsend",
  "flutter.ls_window_offset_x": 510.0,
  "flutter.ls_window_offset_y": 216.0,
  "flutter.ls_window_height": 600.0,
  "flutter.ls_window_width": 900.0,
  "flutter.ls_port": 53317
}



最终改成这样:
{
  "flutter.ls_version": 1,
  "flutter.ls_show_token": "f6ccb2dd-4311-4754-96ad-01eb88bcf5ad",
  "flutter.ls_alias": "Great Lettuce",
  "flutter.ls_security_context": "{\"privateKey\":\"-----BEGIN RSA PRIVATE KEY-----\\nMIIEowIBAAKCAQEApVfrCIXuDnifR6UmobN06hu5/KOY5SGk3WDSF/h6ueMyMQPM\\nSbs646PcUT4SqPO6BeNOIIcIf5HPE2iD4HsxAcJrlBfmSIvS4uoue9sCzPFfhHa6\\n+tSyXEUkIEXEgzb8EQ1QCxzvV2tf6SYBOFO9Ondv7dtrHgiN2SQ45irmwv+Hp+CB\\nP1VWZe1l2exC3j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NTM2\\r\\nWjBQMRcwFQYDVQQDEw5Mb2NhbFNlbmQgVXNlcjEJMAcGA1UEChMAMQkwBwYDVQQL\\r\\nEwAxCTAHBgNVBAcTADEJMAcGA1UECBMAMQkwBwYDVQQGEwAwggEiMA0GCSqGSIb3\\r\\nDQEBAQUAA4IBDwAwggEKAoIBAQClV+sIhe4OeJ9HpSahs3TqG7n8o5jlIaTdYNIX\\r\\n+Hq54zIxA8xJuzrjo9xRPhKo87oF404ghwh/kc8TaIPgezEBwmuUF+ZIi9Li6i57\\r\\n2wLM8V+Edrr61LJcRSQgRcSDNvwRDVALHO9Xa1/pJgE4U706d2/t22seCI3ZJDjm\\r\\nKubC/4en4IE/VVZl7WXZ7ELePfktH1Yd6WqMjm4gOZMYwKPQPV4Ekb1D7tj9Tq6N\\r\\npwuWWzGCvd9ft36yDchUmv00TTCp3Tg1vvIkYbKBnY0OOkas+oYJyJu3ngHH3Qg0\\r\\nypdYTDG+RM2F4tsiU2OzWbpQBNpGX0PjJd89eZMc9YBLMEqHAgMBAAEwDQYJKoZI\\r\\nhvcNAQELBQADggEBAEWdRn2/MPRfGvq0NYNkXt0oa4Taqb7naipzFYrcGRsOeDS+\\r\\nFww1A1Rrr19YxFJQtAUqhoWx/C8VcW0GU4ClUssx7IFAipkEBjSr3WMut9m+N/7X\\r\\ngogbxuoh414LwMztHdNCurqZenS3H5tyRJPBmybrpzhgY9lSaej4z1Et4TsoIFZ9\\r\\nwzHTT+zJNV64KYFJbQUFKulQ2OEnW6mPhgr8OzAUAF2ABimtGvH7EiPaUrUImp7w\\r\\nRg6yb1jECBNUlj0kiAr19CZiEUDHhh15Ql9rNhJeaoU6XASzWdjnsdP3GQNuJBwA\\r\\n3bOYWvLK/9BW67p+a9OnMdz3qUpHAspwlax/eVQ=\\n-----END CERTIFICATE-----\",\"certificateHash\":\"BADC0ED5405CAE1D3AD9857A6DABBD35A363F9B593C58598195FFA066BFFD1FA\"}",
  "flutter.ls_color": "localsend",
  "flutter.ls_window_offset_x": 510.0,
  "flutter.ls_window_offset_y": 216.0,
  "flutter.ls_window_height": 600.0,
  "flutter.ls_window_width": 900.0,
  "flutter.ls_port": 53317,
  "flutter.ls_minimize_to_tray": true,
  "flutter.ls_quick_save": true
}



发表于 2024-1-13 20:07:43 | 显示全部楼层
Local $sSource = ClipGet()
$sAdd = ',' & @CRLF & '  "flutter.ls_minimize_to_tray": true,' & @CRLF & '  "flutter.ls_quick_save": true'
Local $sSRERe = StringRegExpReplace($sSource, '(?<=\V)(?=\v+}\s*$)', $sAdd)
MsgBox(0, '', $sSRERe)

评分

参与人数 1金钱 +40 收起 理由
fybhwsx + 40 很给力!感谢a版!

查看全部评分

您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-12-22 12:15 , Processed in 0.072506 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表