Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a character at a specific position in a string?

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?

like image 642
mmcglynn Avatar asked Aug 05 '15 19:08

mmcglynn


1 Answers

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.

like image 111
dognose Avatar answered Oct 31 '22 21:10

dognose