Formatting with Spaces

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Formatting with Spaces

Viewing 4 reply threads
  • Author
    Replies
    • #59757

      Here’s one method …

      Code:

      hcitcl> set in 1234567890
      hcitcl> regexp {(d{3})(d{3})(d{4})} $in matchAll matchOne matchTwo matchThree
      1
      hcitcl> set new “$matchOne $matchTwo $matchThree”
      hcitcl>echo $new
      123 456 7890

      And here’s another …

      Code:

      hcitcl>regsub {(d{3})(d{3})(d{4})} $in {1 2 3} new
      1
      hcitcl>echo $new
      123 456 7890

      -- Max Drown (Infor)

    • #59758
      David Harrison
      Participant

        Thanks, that works ok but you have to output it as a list.

      • #59759
        Robert Kersemakers
        Participant

          Hi David,

          You almost got it, but your xlateOutVals was a list of three elements and it should be a list of one element: the string “123 456 7890”.

          Max’s solutions absolutely work: just use

          Code:

          set xlateOutVals [list $new]

          Or another option would be to modify your own solution like this:

          Code:

          set xlateOutVals [list [cconcat [string range $xlateInVals 0 2] [string range $xlateInVals 3 5] [string range $xlateInVals 6 end]]]

          Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

        • #59760
          Michael Hertel
          Participant

            xlateInVals is a list too…

            set indata [lindex $xlateInVals 0]

            set xlateOutVals

              -mh

          • #59761
            Robert Kersemakers
            Participant

              Blimey, you’re right! I completely missed that one…

              Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

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