Regex operations on Javascript functions -
i'm trying find function names in javascript , insert following code var functionname = arguments.callee.tostring().substr('function '.length); functionname = functionname .substr(0,functionname .indexof('(')); console.log(functionname); this write name of function console it's called. not having luck this. i've been trying variants of sed.exe: sed "{/function/ s/$/\var ownname = arguments.callee.tostring().substr('function '.length);ownname = ownname.substr(0,ownname.indexof('('));console.log(ownname);/}" *.js this in format sed "/elephant/ s/$/\&castle" *.js anyone have idea how can send i'm appending next line, rather on same line function? also, how can imlement following (but in sed.exe) avoid anonymous function , eval functions?? grep -eho "^s*function w+" *.js | sort thanks help. adding \n replacement string works gnu sed. changed regex have grep ^[[:blank:]]*function...