Reputation: 75
can someone help me with a Notepad++ Regex to replace characters in certain positions? I know there is a lot of answers related to regex, but I'm having a hard time with this, so I apologize if this is a duplicate. Below is what I need done..
Below is a text fixed file where I need to: 1) Replace characters in position 1-3 equal to "622" and replace with "633". 2) Replace characters in position 35-42 to zeroes. This is before:
622021000021833364532 00000202050007037174 JOHN SMITH 0043000264294578
6240631075131010089984136 00000162050006912435 JOHN SMITH 0043000264294622
6242631830492020236 00000025000006912435 JOHN SMITH 0043000264294622
6222631830492020257 00000015000006912435 JOHN SMITH 0043000264294581
6220610001041000142074458 00000202050500002543 JOHN SMITH 0043000264294582
This should be after:
623021000021833364532 00000000000007037174 JOHN SMITH 0043000264294578
6240631075131010089984136 00000000000006912435 JOHN SMITH 0043000264294622
6242631830492020236 00000000000006912435 JOHN SMITH 0043000264294622
6232631830492020257 00000000000006912435 JOHN SMITH 0043000264294581
6230610001041000142074458 00000000000000002543 JOHN SMITH 0043000264294582
Below is what I have so far for request 1: Find: ^(.{3}) This finds the first 3 characters, but I need to find the first 3 characters = to "622". I can't just find "622" because line 2 and 3 have "622" near the end. Those should not be replaced.
Can someone help me with both requests? Any help is much appreciated! Thank you! - Remo
Upvotes: 0
Views: 2128
Reputation: 626896
Find ^622
replace: 633
For 35-42
it's find ^(.{34}).{7}
replace ${1}0000000
(multi-line mode). Both regex are run separately, and once.
Upvotes: 2