April 14th, 2010, 11:10 PM
I have text which can look like any of these:
Perhaps there is a better method then .replace for this? Any help would be greatly appreciated.
April 14th, 2010, 11:16 PM
I guess I could use match
Although that regex returns null
txt = string.match('/\(.*?\)/');
April 17th, 2010, 07:47 AM
That code snippet isn't working as you expect because the forward slashes are used literally because it's a string, so it's silently being converted to a regexp object.
I might do it like this: (the join, replace, and split method calls are to remove the parentheses.)
txt = string.match(/\([^\(\)]+\)/g).join('').replace(/\(|\)$/g,'').split(/\)/);