The file under test will have text patterns like this:
name1: function(){
},
name2: function(){
},
name3: function(){
},
I need to get “name1” “name2” and “name3” in this example.
So used this bash script:
v1='},'
v2=': function'
sed 's/'"$v1"'\(.*\)'"$v2"'/\1/g' test1.js > newfile2
This seems to work only if the pattern shows up like:
},name1: function
But of course the text file is not formatted this way. it’s like this:
},
name1: function
What should I add to the regex that would accomplish what i need?
I do not want to change from using sed
Thanks
1 Answer