I need to edit several lines in a file such that if a line begins with (av or avpgw) then replace these with new text, else just insert the new text in beginning.
H
This might work for you (GNU sed):
sed -r 's/^av(pgw)?.*/replacement/;t;s/^/replacement /' file