Reply To: Regsub cmd to replace multiple occurances

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Regsub cmd to replace multiple occurances Reply To: Regsub cmd to replace multiple occurances

#59421
Lawney Lovell
Participant

    Mike, I used your code but modified slightly because I don’t want to insert an extra space after the formatting characters if it already exists.

    So the expression captures a { follwed by a backslash followed by any number of non-space characters followed by a space.  Then it captures the closing } and puts them together with a space between them.

    Example:

    hcitcl>echo $text

    DURATION}{fs24  }{fs24 OF}{fs24 }{fs24 SERVICE:}

    hcitcl>regsub -all — {({BS*?s)(})} $text {1 2} text

    1

    hcitcl>echo $text

    DURATION}{fs24  }{fs24 OF}{fs24  }{fs24 SERVICE:}

    Thanks for the help!!