Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    checking the first character of a string

    Hi

    Can anyone help please ......

    I need to check to see if the first character of a string is an upper case or lower case letter.


    if ($n32 XXXXXXXXXXXXXXXX ) {
    $in{'filedirname'} = "titles/";
    } else {
    $in{'filedirname'} = "graphics/";
    }


    so if $n32's first letter is ABCDEFGHIJKLMNOPQRSTUVWXYZ then do the fist option .......

    if $n32's first letter is abcdefghijklmnopqrstuvwxyz then do the second option .........

    what should the first line (or several lines before this) be ........



    I would appreciate any help ....

    Thanks

    Snow.

  • #2
    New Coder
    Join Date
    Sep 2002
    Location
    Up North (UK)
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    snowball,

    Try
    Code:
    if( $n32 =~ /^[A-Z]/ )
    {
    	print "Upper case\n";
    }
    else
    {
    	print "Lower case\n";
    }
    This attempts to bind the contents to the regular expression /^[A-Z]/ (the first character is in the set of upper case characters). If it can, the expression is true otherwise false.

  • #3
    New Coder
    Join Date
    Jun 2002
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks ........

    That's exactly it.

    I appreciate it.

    snow.


  •  

    Posting Permissions

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