Ronaldo Killergod Ronaldo Killergod - 1 year ago 93
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.

Answer Source

you want like this?

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download