Regex, replace begin and end of the line

Feb16
  • Share/Bookmark

Difficulty: ★☆☆☆☆

My friend was complaining, he had a whole list of integer numbers, which need to be replaced as a string.
Well instead of replacing line by line, you can use regex (and a nice editor such as Scite or PSPad) I told him:
For example:

123456
124457
147778
121775

to ->

‘123456′,
‘124457′,
‘147778′,
‘121775′,

It’s a piece of cake:
The ^ matches the begin of the line.
The $ matches the end of the line.

//Find
^
//Replace
'

And:

//Find
$
//Replace
',


Leave a comment