sublime支持正则高亮, 但是又不完全支持正则高亮

中括号里面的正斜杠

# 正常写就有问题
/[\\/]node_modules[\\/]/
# 加了escape就OK了
/[\\\/]node_modules[\\\/]/

组织搜索词

  • sublime highlight error
  • use regular expression
  • without escaped slash
  • as character class enclosed in the square brackets
  • sublime highlight regex error when slash without escape in the square brackets
  • sublime highlight regex wrong with square brackets and slash
  • sublime syntax highlight error in regex with square brackets and slash

  • RegEx highlighting is wrong for slashes within sets/ranges

结论

  • 暂时无解
  • 提了bug: https://github.com/sublimehq/sublime_text/issues/5067