xlate help and pattern matching

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf xlate help and pattern matching

  • Creator
    Topic
  • #52234
    Femina Jaffer
    Participant

      Can anyone help me with the following issue:

      I need to check if the mrn is 8 characters, and the first 4 digits are all  alpha and the last 4 digits are all numeric?  Can anyone help me with this, please?

      Thanks.

      Femina

    Viewing 5 reply threads
    • Author
      Replies
      • #73518
        Charlie Bursell
        Participant

          set var ABCD1234

          if {[regexp — {^w{4}d{4}$} $var]} {

                  echo var has 4 characters followed bt 4 digits

          }

        • #73519
          Femina Jaffer
          Participant

            Thank you Charlie!  This really helped.  I was breaking this up in two parts.  Also, thank you Jim K.

            Femina

          • #73520
            Femina Jaffer
            Participant

              Charlie,

              I am still not getting this to work.  I have an example:

              set var 12345678

              if {[regexp — {^w{4}d{4}$} $var]} {

                     echo var has 4 characters followed bt 4 digits

              }

              This still evaluates to true.  It should not pass as it does not meet the condition.

              Please advise.

              Femina

            • #73521
              David Barr
              Participant

                I think that w can match letters or numbers, so you need to do something like this:

                set var 12345678

                if {[regexp — {^[A-Za-z]{4}d{4}$} $var]} {

                      echo var has 4 characters followed bt 4 digits

                }

              • #73522
                Charlie Bursell
                Participant

                  My bad, David is correct w will match all alphanumerics.  Sorry about that.

                  Next time I guess I need to test it better  ðŸ˜€

                • #73523
                  Femina Jaffer
                  Participant

                    That worked – thanks guys!

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