我有多行这样的内容:
{
"source": "Source A",
"target": "Source B",
"idTarget": "3,345",
"strength": "0.5",
"value": "633.5138"
}
{
"source": "Source C",
"target": "Source D",
"idTarget": "1,253",
"strength": "0.7",
"value": "5465.238"
}
我想删除.
包含单词的行中的(点)value
,但不删除其他行中的(点)。因此它看起来像这样:
{
"source": "Source A",
"target": "Source B",
"idTarget": "3,345",
"strength": "0.5",
"value": "6335138"
}
{
"source": "Source C",
"target": "Source D",
"idTarget": "1,253",
"strength": "0.7",
"value": "5465238"
}
有什么办法吗?
答案1
- Ctrl+H
- 找什么:
^"value":[^.]+\K\.
- 用。。。来代替:
LEAVE EMPTY
- 取消勾选匹配大小写
- 检查环绕
- 检查正则表达式
- 请勿检查
. matches newline
- Replace all
解释:
^ : begining of line
"value": : literally
[^.]+ : 1 or more not dot
\K : forget all we have seen until this position
. : a dot
给定示例的结果:
{
"source": "Source A",
"target": "Source B",
"idTarget": "3,345",
"strength": "0.5",
"value": "6335138"
}
{
"source": "Source C",
"target": "Source D",
"idTarget": "1,253",
"strength": "0.7",
"value": "5465238"
}
答案2
假设您的数字始终格式化为 123.1234,则您可以使用正则表达式来实现这一点:
查找内容:"value": "([0-9]+)\.([0-9]+)"
替换为:"value": "$1$2"
搜索模式:正则表达式
此搜索表达式将查找匹配的字符串"value": "<numbers>.<numbers>"
,并将找到的数字放入“捕获组”(用圆括号表示)。然后将两个组($1
, $2
)重新添加到替换的文本中(不带点)。