Use the following instead:
var rgx = /\(([^)]+)\)/; var match = productText.match(rgx); var newText = match && match[1];
When you have /^\(\)$/ , you are actually trying to match the string "()" , no more, no less. Instead, you should match anywhere in the text, ( , store everything between it and the next ) in the capture group ([^)]+) so that you can subsequently refer to the captured group using match[1] .
If you want only a number, use /\(Table (\d+)\)/ .
source share