This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to Parse a string in a rule condition

I have the need to take a string that is used as a Display Name for a database instance in Foglight for SQL Server and parse it.  For instance, the Display name might be something like C-Tier1-DatabaseInstance.   I am building a rule where I have the need to split the string in separate variables to build conditional statements.  What is the syntax to do something like this?

Parents
  • Hi,

    You can try something like this :

    hostName = 'C-Tier1-DatabaseInstance'
    hostNameElements = hostName.split('-')

    Then you can find the parts like this :
    print hostNameElements [0]
    print hostNameElements [1]
    print hostNameElements [2]


    Regards
Reply
  • Hi,

    You can try something like this :

    hostName = 'C-Tier1-DatabaseInstance'
    hostNameElements = hostName.split('-')

    Then you can find the parts like this :
    print hostNameElements [0]
    print hostNameElements [1]
    print hostNameElements [2]


    Regards
Children
No Data