how do i extract the part between the brackets in javascript regular expressions:
answer_postal_address[address]
I tried this:
/^\w*/g
which works but i wasn't sure if this was correct...
how do i extract the part between the brackets in javascript regular expressions:
answer_postal_address[address]
I tried this:
/^\w*/g
which works but i wasn't sure if this was correct...
Matches input
of value of any word character followed by anything inside of bracket, i.e. answer_postal_address[address]
var re = new RegExp("\w+\[([^\]]+)\]");
var m = re.exec(input);
if (m == null) {
alert("No match");
}
else {
alert("Matched: " + m[1]);
}
Shouldn't this be sufficient?
Search for: \([.*?]\)
Replace with: $1
So
result = str.replace(/\((.*?)\)/g, "$1");