<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Regex to get the value from brackets in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/regex-to-get-the-value-from-brackets/m-p/1565864#M222790</link>
    <description>&lt;P&gt;Hello Team,&lt;/P&gt;
&lt;P&gt;We have different values in one of the reference fields in particular table like below&lt;/P&gt;
&lt;P&gt;12345(Aukland)&lt;/P&gt;
&lt;P&gt;098765(namibia)&lt;/P&gt;
&lt;P&gt;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&lt;/P&gt;
&lt;P&gt;Aukland&lt;/P&gt;
&lt;P&gt;Namibia&lt;/P&gt;
&lt;P&gt;Post that we need to verify above values will be avialable in particuler table or not&lt;/P&gt;
&lt;P&gt;Can anyone help on this&lt;/P&gt;
&lt;P&gt;thanks,&lt;/P&gt;
&lt;P&gt;nagesh&lt;/P&gt;</description>
    <pubDate>Wed, 17 Aug 2022 13:57:30 GMT</pubDate>
    <dc:creator>Nagesh5</dc:creator>
    <dc:date>2022-08-17T13:57:30Z</dc:date>
    <item>
      <title>Regex to get the value from brackets</title>
      <link>https://www.servicenow.com/community/developer-forum/regex-to-get-the-value-from-brackets/m-p/1565864#M222790</link>
      <description>&lt;P&gt;Hello Team,&lt;/P&gt;
&lt;P&gt;We have different values in one of the reference fields in particular table like below&lt;/P&gt;
&lt;P&gt;12345(Aukland)&lt;/P&gt;
&lt;P&gt;098765(namibia)&lt;/P&gt;
&lt;P&gt;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&lt;/P&gt;
&lt;P&gt;Aukland&lt;/P&gt;
&lt;P&gt;Namibia&lt;/P&gt;
&lt;P&gt;Post that we need to verify above values will be avialable in particuler table or not&lt;/P&gt;
&lt;P&gt;Can anyone help on this&lt;/P&gt;
&lt;P&gt;thanks,&lt;/P&gt;
&lt;P&gt;nagesh&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 13:57:30 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/regex-to-get-the-value-from-brackets/m-p/1565864#M222790</guid>
      <dc:creator>Nagesh5</dc:creator>
      <dc:date>2022-08-17T13:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to get the value from brackets</title>
      <link>https://www.servicenow.com/community/developer-forum/regex-to-get-the-value-from-brackets/m-p/1565865#M222791</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Try below code -&lt;/P&gt;
&lt;P&gt;var reg = "12345(Aukland)";&lt;BR /&gt;var value = reg.match(/\(([^)]+)\)/)[1];&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Akshay&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 14:02:47 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/regex-to-get-the-value-from-brackets/m-p/1565865#M222791</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2022-08-17T14:02:47Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to get the value from brackets</title>
      <link>https://www.servicenow.com/community/developer-forum/regex-to-get-the-value-from-brackets/m-p/1565866#M222792</link>
      <description>&lt;P&gt;Thanks for the feedback and it's not working in the below example.Can you help me with the below senarios as well becuase some times we have more than 2 names in glide list.&lt;/P&gt;
&lt;P&gt;12345(Aukland),098765(namibia).&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 15:52:28 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/regex-to-get-the-value-from-brackets/m-p/1565866#M222792</guid>
      <dc:creator>Nagesh5</dc:creator>
      <dc:date>2022-08-17T15:52:28Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to get the value from brackets</title>
      <link>https://www.servicenow.com/community/developer-forum/regex-to-get-the-value-from-brackets/m-p/1565867#M222793</link>
      <description>&lt;P&gt;Hi Nagesh,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try the following script in the background script.&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;var str = '12345(Aukland),098765(namibia)';

var arr = str.split(',');

for(var i=0; i&amp;lt;arr.length; i++){
  gs.print(arr[i].match(/\((.*?)\)/)[1]);
}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hopefully, this will help you to resolve your query.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2022 03:49:40 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/regex-to-get-the-value-from-brackets/m-p/1565867#M222793</guid>
      <dc:creator>Muhammad Khan</dc:creator>
      <dc:date>2022-08-18T03:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to get the value from brackets</title>
      <link>https://www.servicenow.com/community/developer-forum/regex-to-get-the-value-from-brackets/m-p/1565868#M222794</link>
      <description>&lt;P&gt;Hi &lt;SN-MENTION class="sn-mention" table="live_profile" sysid="68c4763edb9d64509e691ea6689619e0"&gt;@Nagesh&lt;/SN-MENTION&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can follow below simple javascript functions, which you can also understand and adjust according to your requirements:&lt;/P&gt;
&lt;P&gt;var txt = "12345(Aukland),098765(namibia)";&lt;BR /&gt;var txtArr = txt.split(',');&lt;/P&gt;
&lt;P&gt;for(var i in txtArr){&lt;BR /&gt;&amp;nbsp; &amp;nbsp; var str = txtArr[i];&lt;BR /&gt;&amp;nbsp; &amp;nbsp; gs.info(str.substring(str.indexOf('(') + 1, str.lastIndexOf(')')));&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2022 03:52:40 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/regex-to-get-the-value-from-brackets/m-p/1565868#M222794</guid>
      <dc:creator>Aman Kumar S</dc:creator>
      <dc:date>2022-08-18T03:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to get the value from brackets</title>
      <link>https://www.servicenow.com/community/developer-forum/regex-to-get-the-value-from-brackets/m-p/1565869#M222795</link>
      <description>&lt;P&gt;excellent How to copy these values in glide list with comma seperated.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2022 06:52:58 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/regex-to-get-the-value-from-brackets/m-p/1565869#M222795</guid>
      <dc:creator>Nagesh5</dc:creator>
      <dc:date>2022-08-18T06:52:58Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to get the value from brackets</title>
      <link>https://www.servicenow.com/community/developer-forum/regex-to-get-the-value-from-brackets/m-p/1565870#M222796</link>
      <description>&lt;P&gt;var arrResult = [];&lt;/P&gt;
&lt;P&gt;for(var i in txtArr){&lt;BR /&gt;&amp;nbsp; &amp;nbsp; var str = txtArr[i];&lt;BR /&gt;&amp;nbsp; &amp;nbsp; arrResult.push(str.substring(str.indexOf('(') + 1, str.lastIndexOf(')')));&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;g_form.setValue("list_field",arrResult.toString());// client side&lt;/P&gt;
&lt;P&gt;OR&lt;/P&gt;
&lt;P&gt;current.setvalue("list_field",arrResult.toString());// server side&lt;/P&gt;
&lt;P&gt;I just have one doubt, if it is &lt;STRONG&gt;glidelist &lt;/STRONG&gt;and you are fetching locations, then you will need to glide the &lt;STRONG&gt;cmn_location &lt;/STRONG&gt;table, and get the list and use above function to populate.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2022 14:31:18 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/regex-to-get-the-value-from-brackets/m-p/1565870#M222796</guid>
      <dc:creator>Aman Kumar S</dc:creator>
      <dc:date>2022-08-18T14:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to get the value from brackets</title>
      <link>https://www.servicenow.com/community/developer-forum/regex-to-get-the-value-from-brackets/m-p/1565871#M222797</link>
      <description>&lt;P&gt;this is slightly more succinct than the other answers.&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;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"
]
*/&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Aug 2022 18:50:46 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/regex-to-get-the-value-from-brackets/m-p/1565871#M222797</guid>
      <dc:creator>_ChrisHelming</dc:creator>
      <dc:date>2022-08-26T18:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to get the value from brackets</title>
      <link>https://www.servicenow.com/community/developer-forum/regex-to-get-the-value-from-brackets/m-p/1565872#M222798</link>
      <description>&lt;P&gt;Hi &lt;SN-MENTION class="sn-mention" table="live_profile" sysid="157c9044dbdf7f005129a851ca9619ec"&gt;@Nagesh&lt;/SN-MENTION&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is your issue resolved?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;EM&gt;Feel free to mark correct, if your issue has been resolved, so it ends up in solved queue.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Will be helpful for others looking for the similar query.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2022 22:23:51 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/regex-to-get-the-value-from-brackets/m-p/1565872#M222798</guid>
      <dc:creator>Aman Kumar S</dc:creator>
      <dc:date>2022-08-29T22:23:51Z</dc:date>
    </item>
  </channel>
</rss>

