Search code examples
notepad++

change value in piped delimited text file


I am trying to use Notepad++ and change the value in a text value separated by |

There are 12 columns and I need to change the value in the 10th column to 99999

Program Name|Company Number|Supplier Name|Supplier ID|ID|Phone|Email|Bank Name|Job Number|Project Number|Account Type|Deposit Type|New or Update
AP|555|ABC Corp|V000004||111-111-1111||Franks Bank|11111111|1234|C|CCD|New  
AP|555|ABC Corp|V000004||111-111-1111||Franks Bank|11111123|3456|C|CCD|New

I tried this:

Find :

^(.*?)|^(.*?)|^(.*?)|^(.*?)|^(.*?)|^(.*?)|^(.*?)|^(.*?)|^(.*?)|(.*?)$  

Replace:

^(.*?)|^(.*?)|^(.*?)|^(.*?)|^(.*?)|^(.*?)|^(.*?)|^(.*?)|^(.*?)|9999

It put the value at the right place but wiped everything before and after out.


Solution

    • Ctrl+H
    • Find what: ^(?:[^|]*\|){9}\K[^|]*
    • Replace with: NEW VALUE
    • TICK Wrap around
    • SELECT Regular expression
    • Replace all

    Explanation:

    ^           # beginning of line
    (?:         # non capture group
        [^|]*       # 0 or more any character that is not a pipe
        \|          # a pipe
    ){9}        # end group, must appear 9 times
    \K          # forget all we have seen until this position
    [^|]*       # 0 or more any character that is not a pipe