s = 'one\ntwo\nthree' print(s.replace(/^/mg, '@')) This prints (puts two @@ in the 2nd and subsequent lines): @one @@two @@three Should print: @one @two @three