The character is not replaced, it just inserts the num tabs at the beginning, so you can say that it replaces the โbeginning of lineโ zero-width marker. Whoever wrote this would be better with something more similar:
tabbed = "\t" * num + original
Regular expression is really not the right tool for simple string concatenation.
Explanation: If you expect your line to contain multiple lines, use:
gsub(/^/, "\t" * num)
to prefix all tabbed lines is a sensible thing and less noisy than splitting, prefix and reattaching. If you only expect to deal with one line per line, then a simple string concatenation would be the best choice.
source share