Matt_Breedlove_
Jun 24, 2014Nimbostratus
Help with Scan or String first last and multiple/last occurence
Need some help trying to always match the string immediately preceding the first period and delimited by the leading dash
So given these hostnames, the desired match is indicated...I would be wanting the scan or string command to always return the second string
prod-tools-discovery.acme.com should result in discovery
prod-tools.acme.com should result in tools
prod-io-tools.acme.com should result in tools
stg-io-tools-config.acme.com should result in config
stg-io-tools.acme.com should result in tools
etc
I thought I could do a string reverse on the hostname, split on the last period, then read until the first dash and reverse the result, but irules does not allow "string reverse" I looked at scan and thought that would work, but I can't see how to tell scan to look for the last occurrence of a dash and then read until the first occurrence of a period.
I prefer scan, but if that is not possible can the string commands support skipping to after the last occurrence of a certain character?