in reply to string substitution
What is the problem this is solving ?
You might consider a charactor class a boolean "or" and a start-of-line marker. See perldoc perlre for details