2 Replies Latest reply: May 15, 2014 9:57 AM by Simon Rear RSS

    Replace String Function??

    Simon Rear

      Hello,

       

      I have a requirement to create a calulated field with every occurance of a particular character in another field to be replaced with a specified character.

       

      I understand that  MSRP[/i] would do this globally for the entire data file but is this not possible on a per field basis using an in built function??

       

      I have checked all string functions and am surprised to find no equivilant of, for example, the VBA  Replace[/i]  function.

       

      Any help or advice appreciated,

       

      Regards,

       

      Simon Rear

        • Replace String Function??
          Dee Moore

          At this point Monarch does not have a function to replace characters. But, there is a way to perform this action.......

           

          This expression will replace the lower case "u" with an upper case "X" for the following Sample field:

           

          FIELD_1     -   NEW_FIELD_1

           

          0u4u6       -    0X4X6      

          22u78       -    22X78      

          uu870       -    XX870      

          8t987       -    8t987      

          575u9       -    575X9      

          u983u       -    X983X      

          ci654       -    ci654      

           

          Expression:

           

          If(Substr(Field_1,1,1)="u","X",Substr(Field_1,1,1))+

          If(Substr(Field_1,2,1)="u","X",Substr(Field_1,2,1))+

          If(Substr(Field_1,3,1)="u","X",Substr(Field_1,3,1))+

          If(Substr(Field_1,4,1)="u","X",Substr(Field_1,4,1))+

          If(Substr(Field_1,5,1)="u","X",Substr(Field_1,5,1))

           

          Using Copy & Paste, the Expression builds quickly.

           

          I hope this is helpful.

           

          Dee Moore

          Datawatch Corporation

          Technical Support & Model Building

          978.441.2200

          • Replace String Function??
            Simon Rear

            Thanks for the reply Dee,

             

            I would imagine your suggestion will work ok for small text fields but could reach the maximum expression limit for memo type fields.

             

            A replace function would be nice, or even better expressions with VBA support! Anything like this in the pipline fopr monarch??

             

            Regards,

             

            Simon