regsub challenge

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf regsub challenge

  • Creator
    Topic
  • #48835
    Tom Patton
    Participant

      Having trouble trying to figure out how to do this in one statement…

      Given:

      ~~~Some silly text~ more silly text~~~

      I’m trying to generate:

      ~.~.~Some silly text~ more silly text~.~.~.

      I feed Soarian results and it doesn’t accept the ~~ as a dual carrige return.  If I have any character after the tilde (except space unless there is a character prior to the next ~) the app generates a line feed.  So I’m trying to push periods in to get the app to line feed.

      Thoughts?

    Viewing 3 reply threads
    • Author
      Replies
      • #59844
        Femina Jaffer
        Participant

          Could you not regsub all the tildes “~” and replace with “~,” ?

          FJ

        • #59845
          Tom Patton
          Participant

            I’m trying to _only_ replace the ~ with ~. when there isn’t a space or another character.

            Any ideas?

          • #59846
            Charlie Bursell
            Participant

              The problem is trying to do all of them.

              Try this

              set x “~~~Some silly text~ more silly text~~~”

              while {[regsub -all — {(~)(~)} $x {1 2} x]} {}

              echo $x

              => ~ ~ ~Some silly text~ more silly text~ ~ ~

            • #59847
              Tom Patton
              Participant

                Thank you Charlie – that did the trick!!!

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