You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用Regex仅捕获CLUTCH_BOONS内的+并修复JSON语法问题

Fixing Your Malformed JSON with Regex (Atom/Regexr)

Let's break this down into two straightforward fixes to get your JSON into the desired format.

1. Fix the BOONS Array Syntax & Split the Combined Value

Your BOONS entry is missing the closing bracket ] and needs the + replaced with a comma to split the two values. Here's how to fix it:

  • Open the find-and-replace panel (Atom: Cmd/Ctrl + F, then enable regex mode with the .* icon)
  • In the find field, paste this regex:
    "BOONS": \["([A-Za-z]+)\+([A-Za-z]+)"
    
  • In the replace field, paste:
    "BOONS": ["$1","$2"]
    
  • Run the replacement. This will:
    • Capture the two values separated by + (Debarrier and Rainbow Shift)
    • Replace the + with "," to split them into separate array elements
    • Add the missing closing bracket ] to fix the array syntax

2. Only Replace + Inside CLUTCH_BOONS Array

To target only the + within the CLUTCH_BOONS array (and leave other +s untouched), use this lookaround-based regex:

  • In the find field, paste:
    (?<="CLUTCH_BOONS": \[.*?)(\+)(?=[^\]]*?\])
    
  • Replace matches with:
    ","
    
  • The lookaround assertions ensure we only match + characters that are:
    • After the CLUTCH_BOONS: [` opening
    • Before the corresponding ] closing the array

Final Result

After both steps, your JSON will be corrected to:

"BOONS": ["Debarrier","Rainbow Shift"] }, "CLUTCH_BOONS": [ "Boost","Wall" ],

内容的提问来源于stack exchange,提问作者Ginzo Milani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 07:04:01