regexp and null

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf regexp and null

  • Creator
    Topic
  • #48437
    Anonymous
    Participant

      Clovertechies,

      I am having an issue within regexp to compare a null value.

      Anyone knows a solution please post. What I am trying to do

      is that if the iam_18 field is null then kill it else continue.

      for testing purpose I am doing as follows.

      None of the values inside the braces able to check the $iam_18

      value

      hcitcl>set iam_18 “”         <---- This is how I am setting as a null value. Eevn in the HL7, IAM:18 is blank. hcitcl>echo $iam_18

      hcitcl>regexp {} $iam_18

      0

      Thanks in advance.

      Reggie

    Viewing 2 reply threads
    • Author
      Replies
      • #58632
        Charlie Bursell
        Participant

          First, you are not sending the variable to null, you are setting it the empty string.  This is a difference.

          If you just want to test if it is empty, I prefer to use lempty even though it is a string.  For example:

                                if {[lempty $iam_18]} {d something}

          If something else is setting the field to a true null (Hex 00) then test it like:

                   if {{regexp — {x00} $iam_18]} {do something}

          You really need to use empty string instead of null.  Null has a different connatation.

        • #58633
          Jamin Gray
          Participant

            If by null you mean an empty string, you don’t need a regular expression to test this.  You could use the string equal command:

            Code:


            string equal $iam_18 “”

            will return 1 if $iam_18 is “” otherwise it’ll return 0

            If you really want to use a regular expression:

            Code:


            regexp {^$} $iam_18

            I think what your code is doing is checking if the string matches the null character (octal 0 on the ASCII chart), not checking to see if the string is empty.

          • #58634
            Anonymous
            Participant

              Thanks Charlie and Jamin for your quick response.

              It is really helpful.

              -Reggie-

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