I want to replace increment number using regular expression in TextPad. I have below code and I want increment number between tag <EndToEndId>
and </EndToEndId>
and number should remain 8 digits.
<PmtId>
<EndToEndId>80000001</EndToEndId>
</PmtId>
<PmtTpInf>
<Prtry>PM</Prtry>
</PmtTpInf>
<PmtId>
<PmtId>
<EndToEndId>80000002</EndToEndId>
</PmtId>
<PmtTpInf>
<Prtry>PM</Prtry>
</PmtTpInf>
<PmtId>
......
<PmtId>
<EndToEndId>800000010</EndToEndId>
</PmtId>
<PmtTpInf>
<Prtry>PM</Prtry>
</PmtTpInf>
<PmtId>
I have tried myself to come up with solution but after 80000009, it gives 800000010 which is 9 digit number.
I have provided below regular expression in Find And Replace option in TextPad.
Find What: (<EndToEndId>).*?(</EndToEndId>)
Replace With: (<EndToEndId>)\i(</EndToEndId>)
I have searched similar solution on Stackoverflow using Notepadd++ from Notepad++ incrementally replace
but it doens't give increment number when there are other tags like <PmtId>, <PmtTpInf>
Could you please help me to solve this issue as I have tried myself a lot and now asking on Stackoverflow. Thank you.
Do two passes.
The first pass as you are currently doing, producing results like:
80000001
80000009
800000010
800000099
8000000100
8000000999
then a second pass to correct the lengths:
Search: 80+(\d{6})\b
Replace: 8$1
Which produces the following result from the above sample intermediate output:
8000001
8000009
8000010
8000099
8000100
8000999