I want
ereg ($rat, $dog, $cat)
to become
preg_match (\'#\'.$rat.\'#\', $dog, $cat)
To achieve this, I did
How about:
$ echo 'ereg ($rat, $dog, $cat)' | sed "s/ereg *(\([^,]*\), \([^,]*\)\([^)]*\))/preg_match('#'.\1.'#', \2\3)/g" preg_match('#'.$rat.'#', $dog, $cat)