[英]How to use regular expressions in VS Code
I have a question about regular expressions.我有一个关于正则表达式的问题。 I'm using VS Code and trying to search and replace € (price).
我正在使用 VS Code 并尝试搜索和替换 €(价格)。
I have a JSON file and in that file a have price like this: "price": 120.000 € a trying to remove € so everything should look like this: "price": 120.000 Please help, thank you all.我有一个 JSON 文件,在该文件中的价格是这样的:“price”:120.000 € a 试图删除 € 所以一切都应该是这样的:“price”:120.000 请帮忙,谢谢大家。
("price"\\s?:\\s?"(?:\\d+\\.?)+)(\\s?€)"
to be replaced by $1"
("price"\\s?:\\s?"(?:\\d+\\.?)+)(\\s?€)"
替换为$1"
$1
is the first captured group. $1
是第一个捕获的组。 In that RegEx, this is : ("price"\\s?:\\s?"(?:\\d+\\.?)+)
在那个正则表达式中,这是 :
("price"\\s?:\\s?"(?:\\d+\\.?)+)
("price"\\s?:\\s?"(?:\\d+\\.?)+)
:("price"\\s?:\\s?"(?:\\d+\\.?)+)
: -> "price"
matches the characters "price"
literally (case sensitive) ->
"price"
字面上匹配字符"price"
(区分大小写)
-> \\s
matches any whitespace character (equal to [\\r\\n\\t\\f\\v ]
) ->
\\s
匹配任何空白字符(等于[\\r\\n\\t\\f\\v ]
)
--> ?
-->
?
Quantifier — Matches between zero and one times, as many times as possible, giving back as needed (greedy)量词 - 匹配零次和一次,尽可能多次,根据需要回馈(贪婪)
-> :
matches the character :
literally (case sensitive) ->
:
匹配字符:
字面意思(区分大小写)
-> \\s
matches any whitespace character (equal to [\\r\\n\\t\\f\\v ]
) ->
\\s
匹配任何空白字符(等于[\\r\\n\\t\\f\\v ]
)
--> ?
-->
?
Quantifier — Matches between zero and one times, as many times as possible, giving back as needed (greedy)量词 - 匹配零次和一次,尽可能多次,根据需要回馈(贪婪)
-> "
matches the character "
literally (case sensitive) ->
"
匹配字符"
字面意思(区分大小写)
(?:\\d+\\.?)+
(?:\\d+\\.?)+
-> +
Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy) ->
+
Quantifier — 匹配一次和无限次,尽可能多次,根据需要回馈(贪婪)
--> \\d+
matches a digit (equal to [0-9]
) -->
\\d+
匹配一个数字(等于[0-9]
)
--> \\.?
-->
\\.?
matches the character .
匹配字符
.
literally (case sensitive)字面意思(区分大小写)
(\\s?€)
(\\s?€)
-> \\s
matches any whitespace character (equal to [\\r\\n\\t\\f\\v ]
) ->
\\s
匹配任何空白字符(等于[\\r\\n\\t\\f\\v ]
)
--> ?
-->
?
Quantifier — Matches between zero and one times, as many times as possible, giving back as needed (greedy)量词 - 匹配零次和一次,尽可能多次,根据需要回馈(贪婪)
-> €
matches the character €
literally (case sensitive) ->
€
从字面上匹配字符€
(区分大小写)
-> "
matches the character "
literally (case sensitive) ->
"
匹配字符"
字面意思(区分大小写)
This will be replaced by $1"
which is the first captured group followed by "
这将被替换为
$1"
,这是第一个捕获的组,然后是"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.