Incognito
Incognito

Reputation: 455

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?

Upvotes: 1

Views: 780

Answers (2)

MannyCalavera
MannyCalavera

Reputation: 53

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

Upvotes: 3

Tim Pietzcker
Tim Pietzcker

Reputation: 336468

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.

Upvotes: 4

Related Questions