ServiceNow Regex: retrieve a url section

 var sStr="https://xxxx.live.dynatrace.com/#problems/problemdetails;pid=-400331722456210xxxx_16526899800xxxx";

var iMatch1=sStr.indexOf("/", sStr.indexOf("/")+1);
var iMatch2=sStr.indexOf("/", sStr.indexOf("/")+2);
//gs.print(iMatch2);

gs.print(sStr.substring(iMatch1+1, iMatch2));

 ---

 output:

*** Script: 35
*** Script: xxxx.live.dynatrace.com

 

Comments

Popular posts from this blog

GlideRecord setValue

URL link in addInfoMessage