12

I am using Notepad++ and want to insert a character at a specific position in a string using regular expression replacement.

What would the expressions be to, say, insert a comma at position 6 of every row?

Cœur
  • 37,241
  • 25
  • 195
  • 267
mmcglynn
  • 7,668
  • 16
  • 52
  • 76

1 Answers1

21

If you want to add a character after the sixth character, simple use the search

^(.{6})

and the replacement

$1,

(Example inserts a ,)

technically spoken this will replace the first 6 characters of every line with MatchGroup 1 (backreference $1) followed by a comma.

dognose
  • 20,360
  • 9
  • 61
  • 107