regsub question

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf regsub question

  • Creator
    Topic
  • #54356
    Shu Chen
    Participant

      hi clovertech:

      is it possible use regsub to replace “~~” or “~~~” into “~” in TCL since “~” is encoding char in hl7 message

      regsub -ALL {~~|~~~} $IN {~} OUT?

      I am not sure the sytax is correct or not.

      thanks for your help

      best

    Viewing 3 reply threads
    • Author
      Replies
      • #81144
        Brandon Grudt
        Participant

          I may not understand the nuances here, but on it’s face, that seems like something I would use “string map” for.  I’ve used string map on HL7 characters before, without issue.  Without testing it, I think the command would be:

          set out [string map { ~~ ~ ~~~ ~ } $in]

        • #81145
          Charlie Bursell
          Participant

            It is not something you would do in Xlate but perhaps a route pre-proc

            If there are always 2 or three the string map as recommended by Brandon would be your best bet.  However if you want to collapse any number of ~ into one you would do something like:  (Assumes msg holds HL7 message)

                regsub -all — {~+} $msg {~} msg

            The plus sign above says look for one or more

          • #81146
            Jim Kosloskey
            Participant

              If you are using an Xlate you may be able to  accomplish what you want by using a field ITERATE.

              I would need to have more information though.

              email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

            • #81147
              Shu Chen
              Participant

                thanks guys. works great!!!!

                hi Jim, I figured it out this one. thanks for you help.

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