Search code examples
regexnotepad++textpad

Remove 8 char, save 4, remove 4, save 4, replace 1 and keep rest of the line


In every line I would like to:

  • remove char 1-8 (8)
  • save char 9-12 (4)
  • remove char 13-16 (4)
  • save char 17-20 (4)
  • replace char 21 (1) with space
  • keep the rest of line

and then do it for every line

I have started with:

^.{8}(.{4}).{4}

Is it possible to in oneline or repeat the pattern...

(I use Notepad++ and TextPad)


Solution

  • This should do the trick. Simply count the characters as you've done and replace with the capture groups and a space.

    Find

    ^.{8}(.{4}).{4}(.{4})(.{1})
    

    Replace (incl. the space after $2)

    $1$2 
    

    https://i.gyazo.com/e0b5d392caaaccfb8747cc15e37e3e96.gif