简体   繁体   English

Notepad ++:查找并替换为正则表达式

[英]Notepad++: Find & replace with regular expressions

Hi there im having in multiple files the text below and i want to change them with Notepad++. 嗨,我在多个文件中有以下文本,我想用记事本++更改它们。 I've searched the internet and many "guyides" but no luck yet. 我已经搜索了互联网和许多“ guyides”,但还没有走运。

<ingredient id="57" count="10000000"/>

and i want to do it like this 我想这样做

<ingredient id="57" count="10000000" isTaxIngredient="true" />

the count is always integer. 该计数始终为整数。

Im searching for this 我正在寻找这个

<ingredient id="57" count="\d+"/>

and replace all with this 并全部替换为

<ingredient id="57" count="\1" isTaxIngredient="true" />

How my expression should be? 我的表情应该如何?

The only thing missing are parentheses that show which part of the regex match you want to capture in backreference \\1 : 唯一缺少的是括号,该括号显示要在后向引用\\1捕获的正则表达式的哪一部分匹配:

<ingredient id="57" count="(\d+)"/>

should work. 应该管用。

You simply forgot the parenthesis around your \\d+ 您只是忘记了\\ d +周围的括号

<ingredient id="57" count="(\d+)"/>

This tells notepad++ the different group that you want it to match (and retreive using the backreferences) 这会告诉notepad ++您希望其匹配的不同组(并使用反向引用检索)

Regards, 问候,

Manny 曼尼

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

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