简体   繁体   English

正则表达式替换Notepad ++

[英]Regular Expression replacement Notepad++

I am modifying a json file for Rust with the Oxide mod and I am unfamiliar with programming in general. 我正在使用Oxide mod修改Rust的json文件,我对编程一般不熟悉。

I need to replace several instances of "stackable": 64.0, with "stackable": 15000.0, 我需要替换“stackable”的几个实例:64.0,“stackable”:15000.0,

The value is not always "64.0". 该值不总是“64.0”。 There are instances of "1000.0" and "1.0" etc... 有“1000.0”和“1.0”等实例......

What I am currently doing is: 我目前正在做的是:

Search for: "stackable":/*/*/*/*
Replace with: "stackable": 15000.0,

This replaces the text that I want but essentially the end result is it simply enters the text in before the default value. 这取代了我想要的文本,但最终的结果是它只是在默认值之前输入文本。 So a line will end up looking like 所以一条线最终看起来像

"stackable": 15000.0, 64.,

How can I replace using wildcards but also remove the default value? 如何使用通配符替换,还要删除默认值?

First match "stackable" and then match spaces if any and then match numbers with . 首先匹配“可堆叠”然后匹配空格(如果有)然后匹配数字. in them, using a character class. 在其中,使用一个字符类。

Find: (stackable)\s*[\d.]+
Replace: $1: 15000.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM