Syntax for finding period (.) in email TLD

Clovertech Forums Read Only Archives Cloverleaf Tcl Library Syntax for finding period (.) in email TLD

  • Creator
    Topic
  • #50542
    Thomas Fortino
    Participant

      Hello All,

       I wrote a brief XLTP tclproc a few months ago to send an email address if there was anything before and after the @. I have to update the tcproc to look for the TLD (Top Level Domain), and send email address if there is something after the (.) period but I can’t get the syntax correct.

      Example –

      SEND  – xxxxx@aol.com

      Send nothing – xxxxx@aol

      Below is a portion of the XLTP proc currently in use.

                set email {}

                set email2 {}

             

               if [regexp — {.+@.+} [lindex $xlateInVals 0]] {

           

                  set email [lindex $xlateInVals 0]

                               

               } else {

                 

                 set email $email2

         

      }

       set xlateOutVals

               }

    Viewing 2 reply threads
    • Author
      Replies
      • #66540
        Tom Rioux
        Participant

          Hey Tom….I think this may work for you.  Try it and let me know if it is what you are looking for.   Here is what I’ve done:

          set email tomr@aol.com

          set email2 tomr@aol

          set email3 @aol.com

          set email4 tomr@aol.

          Here are the results from each:

          hcitcl>regexp — {(.+@)(.+..+)} $email

          1

          hcitcl>regexp — {(.+@)(.+..+)} $email2

          0

          hcitcl>regexp — {(.+@)(.+..+)} $email3

          0

          hcitcl>regexp — {(.+@)(.+..+)} $email4

          0

          Hope this helps…

          Tom Rioux

        • #66541
          Jim Kosloskey
          Participant

            Tom,

            Here is another method:

            Use the file Tcl command with the extension attribute.

            Assuming my_variable has your email address ( xxxxx@aol.com ):

            file extension $my_variable will return .com – if there was no extension, null would be returned.

            So you can just do a simple if with a string equal and the file extension to see if the extension exists.

            An added note: to get the stuff in front of the extension, use file rootname.

            email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

          • #66542
            Thomas Fortino
            Participant

              Thanks Tom for your reply. I just tried your regexp using tclx and it worked great. I going to update the XLTP and then test out the translation using real data. Thank again for your help.

              Jim thanks for your reply as well.

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