fix_regex2.py 911 B

12345678910111213141516171819202122
  1. # -*- coding: utf-8 -*-
  2. with open('d:/caidawork/openclaw-voc-skill/claude-code/claude-code-qiwe-assistant/mcp/src/dashboard/app.js', 'r', encoding='utf-8') as f:
  3. lines = f.readlines()
  4. # 找到并修复所有被拆分的 split(/\n|\r/)
  5. i = 0
  6. while i < len(lines):
  7. line = lines[i]
  8. # 匹配 .split(/ 后跟换行,下一行是 |,再下一行是 /)
  9. if '.split(/' in line and line.rstrip().endswith('split(/'):
  10. if i + 2 < len(lines) and lines[i+1].strip() == '|' and lines[i+2].strip().startswith('/).map'):
  11. indent = line[:len(line) - len(line.lstrip())]
  12. lines[i] = line.replace('split(/', 'split(/\\n|\\r/')
  13. del lines[i+1:i+3]
  14. continue
  15. i += 1
  16. with open('d:/caidawork/openclaw-voc-skill/claude-code/claude-code-qiwe-assistant/mcp/src/dashboard/app.js', 'w', encoding='utf-8') as f:
  17. f.writelines(lines)
  18. print('fixed split regex')