I need to extract number from string like
<p id="example">etc etc(5)</p>
<p id="example2">etc etc(-5)</p>
I'm using this code
alert($("#example").text().match(/\((\d+)\)/)[1]);
It's work fine if the number is positive but in the case of a negative number get error
Uncaught TypeError: Cannot read property '1' of null
please help me about that thank's