Tcl regex Vs. Java regex (Cloverleaf GUI)

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Tcl regex Vs. Java regex (Cloverleaf GUI)

  • Creator
    Topic
  • #55177
    Charlie Bursell
    Participant

      I have had some that have used the grepDB script ask about why a regexp that works in Tcl does not work in the SMAT DB GUI so, even though it is documented, (who reads docs)  ðŸ˜€  I thought I would post this.

      Copied from my script comments so 80 byte lines.

      A note about using regular expressions in Tcl vs using regular expressions

      in the SMAT DB GUI (Java)

      The Cloverleaf documentation states that Java, by default, does not treat

      CR or NL as regular characters so a dot (.) would not recognize a CR or NL

      and you must use the expression (?s) to cause the Java regexp engine

      to treat CR NL as regular characters so you can search across segments.

      Tcl regexp is just the opposite.  By default, CR and NL are treated as

      just regular charaters so a search like ORU.*OBR would work OK in Tcl

      while in Java (CL GUI) it would be like (?s)ORU.*OBR.  To emulate the

      Java behavior in Tcl use (?n) whch is equivalent to the -line option

      when using the Tcl regex command.

      Be aware of this when trying to use regular expressions in any

      Tcl procedure then use the same in the CL SMAT DB GUI or vice versa!

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