Regex in Service Mapping

AmbikaSekar1010
Tera Contributor

Hello All,

 

Could anyone please help me with the Regex pattern to get the server name and port number from this command Output?

 

coupler.ports=servername1:portnumber1,servername2:portnumber2,servername3:portnumber3,servername4:portnumber4

 

I have used the pattern below, but it only returns the first server, how can I get all the server names and port numbers 

 

(servername[0-9][0-9][0-9][0-9]):([0-9][0-9][0-9][0-9][0-9])

2 REPLIES 2

Appli
Mega Sage
Mega Sage

Hi, you can use different regex.

var rgx = /(servername\d+):(\d+)/g;
var results = input.match(rgx);
gs.info (results[0]+','+results[1]+','+results[2]+','+results[3]);
Hope it helps

AmbikaSekar1010
Tera Contributor

@Appli  Thanks for your reply..

This is not returning, also we need to use this in Service Mapping Discovery Patterns, so we cannot use array