matching a complex regexp

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf matching a complex regexp

  • Creator
    Topic
  • #48848
    Jennifer Shepard
    Participant

      Hi guys,

      So I am trying to match the following string in an RTF document:

      {*bkmkend InsertPictureHere}

      Then I want to build a long replace statement as follows, based on facility:

                          # Build find/replace strings to insert logo path

                           set find “{\*\bkmkend InsertPictureHere}”

                           echo FIND: $find

                           

                           set replace “{\field {\*\fldinst {\rtlch\fcs1 \af0\afs16 \ltrch\fcs0 \fs16 INCLUDEPICTURE “

                          #set replace2 according to facility

                            if {$sendFac == “A”} {

                            set replace2 “”G:\SHARED\DRBitmaps\SARMC.tif””

                            }

                            if [regexp — {84|269|211|5399} $recvFac] {

                            set replace2 “”G:\SHARED\DRBitmaps\IMI.tif””

                            }

                            if {$sendFac == “TMC”} {

                            set replace2 “”G:\SHARED\DRBitmaps\TAMjoi01.tif””

                            }

                            set replace3 ” \\* MERGEFORMAT \\d }} {\fldrslt {\rtlch\fcs1 \af0\afs16 \ltrch\fcs0 \fs16 }}} {\*\bkmkend InsertPictureHere}”

                            append replace $replace2 $replace3

                            echo REPLACE: $replace

                           #regsub -all — $find $report $replace report

                           regsub -all — $find $report $replace report

      I am not able to match {*bkmkend InsertPictureHere} in my report. I tried {*bkmkendsInsertPictureHere}, also.

      Also, once I figure out my match problem, will a regsub work ok when I’m using so many variables?

      Any ideas what could be happening?

      Thanks in advnace

    Viewing 1 reply thread
    • Author
      Replies
      • #59904
        Chris Williams
        Participant

          Try changing

           set find “{\*\bkmkend InsertPictureHere}”

          to

           set find {{\*\bkmkend InsertPictureHere}}

          Use braces around your value rather than quotes.

          Don’t forget to escape the asterisk.

          Cheers from a former Boisean.

        • #59905
          Mike Grieger
          Participant

            I’ll throw in an attempt as well – this is what I entered in the testing tool which worked:

            set find “{\\\*\\bkmkend InsertPictureHere}”

            regsub -all $find $report $replace report2

            Test input:

            {dummy data}{START!!}{*bkmkend InsertPictureHere}{STOP!!}{more dummy data }{dummy data}{START!!}{*bkmkend InsertPictureHere}{STOP!!}{dummy data }{\fs24 SEEN:}{\fs24 }{\fs24 }

            Test output:

            {dummy data}{START!!}{field {*fldinst {rtlchfcs1 af0afs16 ltrchfcs0 fs16 INCLUDEPICTURE “G:SHAREDDRBitmapsSARMC.tif” * MERGEFORMAT d }} {fldrslt {rtlchfcs1 af0afs16 ltrchfcs0 fs16 }}} {*bkmkend InsertPictureHere}{STOP!!}{more dummy data }{dummy data}{START!!}{field {*fldinst {rtlchfcs1 af0afs16 ltrchfcs0 fs16 INCLUDEPICTURE “G:SHAREDDRBitmapsSARMC.tif” * MERGEFORMAT d }} {fldrslt {rtlchfcs1 af0afs16 ltrchfcs0 fs16 }}} {*bkmkend InsertPictureHere}{STOP!!}{dummy data }{\fs24 SEEN:}{\fs24 }{\fs24 }

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