nCardot
nCardot

Reputation: 6587

Finding and replacing variable digits with regular expression in notepad++

I need to replace 16.16.XXX"> with 16.16.XXXA">, where X represents any digit, using notepad++'s find and replace feature. I just need to add the A but keep the other numbers (the last three digits represented by X are variable).

I know little about regexes, but I tried entering 16.16.\d\d\d"> in the "find" field and tried to replace it with 16.16.\d\d\dA">, but this replaced the variable digits with \d\d\d rather than their original digits.

Upvotes: 4

Views: 1188

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 626747

Use

Find what: (16\.16\.\d{3})(">)
Replace with: $1A$2

Details

  • (16\.16\.\d{3}) - Group 1: 16.16. and any 3 digits (\d{3})
  • (">) - Group 2: "> substring.

The $1 and $2 are backreferences that refer to the values captured with the corresponding capturing groups.

enter image description here

Upvotes: 2

Related Questions