How to replace a particular string in MRL ?

Version 1
    Share This:

    This document contains official content from the BMC Software Knowledge Base. It is automatically updated when the knowledge article is modified.


    PRODUCT:

    BMC Event Manager Base


    APPLIES TO:

    BMC Event Manager Base



    QUESTION:

    I would like to replace a string in an event to something else. How can I do that in MRL ?
     


    ANSWER:

     

    Legacy ID:KA401179

      

    The strreplace primitive can be used for this. It is available in cell version 7.4 and higher.

      

    The following example replaces all spaces with an underscore:

      

    $EV.msg = strreplace($EV.msg,' ','_')

      

    All spaces are replaced with underscores for the msg slot of the event that is
    represented by the variable $EV.

      


    The following example replaces two occurrences of and with or:

      

    $NEWSTR = strreplace('and: o tempanda o mandes','and','or',2)

      

    The resulting string is $NEWSTR='or: o tempora o mandes'. The first two occurrences of and have been replaced with or.

      


    The following example replaces two occurrences of and with or, skipping the first occurrence:

      

    $NEWSTR = strreplace('and: o tempanda o mandes','and','or',2,1)

      

    The resulting string is $NEWSTR='and: o tempora o mores'. The first occurrence of and is left as it is, and the following two occurrences of and have been replaced with or.

      
    Related Products:  
       
    1. BMC ProactiveNet Performance Management Suite
    2.  
    3. BMC ProactiveNet Performance Management Suite

     


    Article Number:

    000022157


    Article Type:

    FAQ/Procedural



      Looking for additional information?    Search BMC Support  or  Browse Knowledge Articles