简体   繁体   中英

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.

<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 :

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

should work.

You simply forgot the parenthesis around your \\d+

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

This tells notepad++ the different group that you want it to match (and retreive using the backreferences)

Regards,

Manny

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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