Regex to get the value from brackets

Nagesh5
Tera Contributor

Hello Team,

We have different values in one of the reference fields in particular table like below

12345(Aukland)

098765(namibia)

We need help to filter the values in the brackets only with the help of regex like below by removing all the values other than values in brackets

Aukland

Namibia

Post that we need to verify above values will be avialable in particuler table or not

Can anyone help on this

thanks,

nagesh

8 REPLIES 8

excellent How to copy these values in glide list with comma seperated.

var arrResult = [];

for(var i in txtArr){
    var str = txtArr[i];
    arrResult.push(str.substring(str.indexOf('(') + 1, str.lastIndexOf(')')));
}

g_form.setValue("list_field",arrResult.toString());// client side

OR

current.setvalue("list_field",arrResult.toString());// server side

I just have one doubt, if it is glidelist and you are fetching locations, then you will need to glide the cmn_location table, and get the list and use above function to populate.

Best Regards
Aman Kumar

Hi @Nagesh 

Is your issue resolved?


Feel free to mark correct, if your issue has been resolved, so it ends up in solved queue.

Will be helpful for others looking for the similar query.

Best Regards
Aman Kumar

_ChrisHelming
Tera Guru

this is slightly more succinct than the other answers.

var input ='12345(Aukland),098765(namibia),098765(botswana),098765(quebec),098765(new york),098765(toronto),098765(kiev),098765(tokyo),098765(mumbai).'

input.match(/\(([^)]+)\)/g).map(function(m){return m.replace(/[()]/g,'')});

/*
[
  "Aukland",
  "namibia",
  "botswana",
  "quebec",
  "new york",
  "toronto",
  "kiev",
  "tokyo",
  "mumbai"
]
*/