正则表达式用_替换带引号的字符串中的空格(崇高)
Regex to replace spaces in quoted strings with _ (Sublime)
我正在尝试通过删除 spaces(如果有的话)来修改我的 JSON 文件(大约 60 MB)中的键。我使用 Sublime Text Editor 加载和编辑大型 JSONs.
目前,我正在使用以下表达式查找带有 spaces 的引用字符串:
"([a-zA-Z])+([\s])+([a-zA-Z]*)":
查找:“名字”:
然后我使用以下表达式将 space 替换为匹配字符串的下划线:
"_":
结果: "t_Name":
预期:“第一t_Name”:
我不明白为什么我无法用 $1 捕获第一个单词。任何帮助,将不胜感激。谢谢!
注意:JSON.
中有大约15000个不同的键space
使用
"([a-zA-Z]+)\s+([a-zA-Z]*)":
说明
--------------------------------------------------------------------------------
" '"'
--------------------------------------------------------------------------------
( group and capture to :
--------------------------------------------------------------------------------
[a-zA-Z]+ any character of: 'a' to 'z', 'A' to 'Z'
(1 or more times (matching the most
amount possible))
--------------------------------------------------------------------------------
) end of
--------------------------------------------------------------------------------
\s+ whitespace (\n, \r, \t, \f, and " ") (1 or
more times (matching the most amount
possible))
--------------------------------------------------------------------------------
( group and capture to :
--------------------------------------------------------------------------------
[a-zA-Z]* any character of: 'a' to 'z', 'A' to 'Z'
(0 or more times (matching the most
amount possible))
--------------------------------------------------------------------------------
) end of
--------------------------------------------------------------------------------
": '":'
我正在尝试通过删除 spaces(如果有的话)来修改我的 JSON 文件(大约 60 MB)中的键。我使用 Sublime Text Editor 加载和编辑大型 JSONs.
目前,我正在使用以下表达式查找带有 spaces 的引用字符串:
"([a-zA-Z])+([\s])+([a-zA-Z]*)":
查找:“名字”:
然后我使用以下表达式将 space 替换为匹配字符串的下划线:
"_":
结果: "t_Name":
预期:“第一t_Name”:
我不明白为什么我无法用 $1 捕获第一个单词。任何帮助,将不胜感激。谢谢!
注意:JSON.
中有大约15000个不同的键space使用
"([a-zA-Z]+)\s+([a-zA-Z]*)":
说明
--------------------------------------------------------------------------------
" '"'
--------------------------------------------------------------------------------
( group and capture to :
--------------------------------------------------------------------------------
[a-zA-Z]+ any character of: 'a' to 'z', 'A' to 'Z'
(1 or more times (matching the most
amount possible))
--------------------------------------------------------------------------------
) end of
--------------------------------------------------------------------------------
\s+ whitespace (\n, \r, \t, \f, and " ") (1 or
more times (matching the most amount
possible))
--------------------------------------------------------------------------------
( group and capture to :
--------------------------------------------------------------------------------
[a-zA-Z]* any character of: 'a' to 'z', 'A' to 'Z'
(0 or more times (matching the most
amount possible))
--------------------------------------------------------------------------------
) end of
--------------------------------------------------------------------------------
": '":'