Ronaldo Killergod Ronaldo Killergod - 6 months ago 32
Javascript Question

Best way of extracting substring from a string by regex - javascript (string value below)

var stringname="function func() {alert('testing savecallback2');}"

This is the string value I was having hard time extracting.
I want to extract "func()" or any name that appends with "()".

Please help me up.


you want like this?

var arr = "function func() {alert('testing savecallback2');}".match(/\s([A-Za-z0-9]+\(\))\s/);