Remove multiple strings

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Remove multiple strings

  • Creator
    Topic
  • #52787
    Tim Hallbauer
    Participant

      Hi All.

      I have a situation where I need to remove all occurrences of a string from a message. The string is CD:  followed by various numbers. The string length isn’t always the same and can appear anywhere in the transaction. It may be preceeded or followed by a field separator, repetition separator etc. So it can be CD:1234  or CD:1459302. I have looked using the search function and tried several things, but the best I have done so far is remove the CD: but the following numbers still appear.

      Tim

    Viewing 2 reply threads
    • Author
      Replies
      • #75475
        Keith McLeod
        Participant

          Have you tried using regular expressions?

          regsub -all — {CD:d+} $msg {} new_msg

          something like this should match CD: and replace with blank or null.

        • #75476
          Tim Hallbauer
          Participant

            Keith,

            Thanks. I was just going to post that I had resolved the issue using something from a post I found. It is very similar to what you suggested.

            regsub -all {CD:d*} $msgdata “” newMsg

            Tim

          • #75477
            Keith McLeod
            Participant

              The * represents 0 or more numbers following CD:.  whereas the + is 1 or more, just in case that makes a difference.

          Viewing 2 reply threads
          • The forum ‘Cloverleaf’ is closed to new topics and replies.