www.webdeveloper.com
Results 1 to 2 of 2

Thread: How to write a "if" loop to compare whether the

  1. #1
    Join Date
    Apr 2003
    Location
    HK
    Posts
    7

    Question How to write a "if" loop to compare whether the

    How to write a "if" loop to compare whether the
    variable $a equal to (a-z and A-Z)??

    e.g.

    $a="Hello"
    $b="!!!"

    if variable $b is not equal to (a-z and A-Z)
    then
    {
    statement;
    };

  2. #2
    Join Date
    Nov 2002
    Location
    NY, USA
    Posts
    731
    Well, for starters, if is not a loop. And second, what exactly do you mean equal to a-z and A-Z? Do you mean if $a contains at least one letter? If so then this can be done easily with a regular expression match.
    Code:
    if ($a =~ /[a-z]/i) {
        # it has a letter
    }
    
    if ($b !~ /[a-z]/i) {
        # it doesn't have a letter
    }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles