I have this string : Charles de Gaulle, (Paris) [CDG]
I would like in JavaScript/jQuery get just Paris
. The initial string can have variable length.
I have tried this:
var tab = "Charles de Gaulle, (Paris) [CDG]";
var tab2 = tab.split(',');
var tab3 = tab2.split('[')
Try
var myString= "Charles de Gaulle, (Paris) [CDG]";
var result = myString.match(/\((.*)\)/);
alert(result[1]);
DEMO
You can use .slice(begin,end)
instead of .substring()
.
For example click on the link to view your result: http://jsfiddle.net/qhZq5/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With