hihaho67
hihaho67

Reputation: 99

Jquery Splice or Split by '('

I have values like: "Kurt Cobain (13)". Obviously without the double quotes. I'm looking to fetch the value within the round brackets. The values are in a table in 's.

I've used .each to get ( this ).html to fetch the whole value, then was thinking of using .split("(") rather than slice since the values inside the brackets vary. The key is to start from the back of the value and store everything from the back till the "(".

any ideas anyone?

Thanks,

Ian

Upvotes: 2

Views: 150

Answers (1)

Rajaprabhu Aravindasamy
Rajaprabhu Aravindasamy

Reputation: 67207

Try,

var x = "Kurt Cobain (13)";
x.substring(x.indexOf('(') + 1,x.indexOf(')'));

DEMO

Upvotes: 4

Related Questions