I need to get multiple texts from more than one set of parentheses, and if there is no more than one set then I need to get text from only that single set of parentheses.
1) Example :
My sentence is :
A Cef (1000mg) (Sterlie Ceftriaxone) Price List.
Now, I need to get the output like this :
Output :
1000mg Sterlie Ceftriaxone
2) Also if I have only single set like this : Aamin A (Atenolol) Price List.
Then my output should be : Atenolol
I am using this javascript code :
function myFunction() {
var str = "A Cef (1000mg) (Sterlie Ceftriaxone) Price List.";
var res = str.match(/\((.*))\)/);
document.getElementById("demo").innerHTML = res[1];
}
It is perfectly working for the 2nd case but when I am using it for the 1st one it giving me this output.
Output :1000mg) (Sterlie Ceftriaxone