Regex in Service Mapping
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2024 05:20 AM
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2024 06:00 AM
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2024 06:30 AM
@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