SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Checking for 1 letter and 1 number in a string.

    I've searched the forums an come up empty handed. I'd like to verify a string has at least 1 letter and at least 1 number without using RegEx, is there a simple way?

    Thanks!

  2. #2
    SitePoint Enthusiast traxxas's Avatar
    Join Date
    Jan 2007
    Location
    San Diego, CA
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    RegEx is the easiest way, but if you don't want to use that you'll have to walk the string like its an array checking each character for your two cases.

  3. #3
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, you're right, got this far!

    PHP Code:
    if(!eregi("[A-Z]",$string))

    if(!
    ereg("[0-9]",$string)) 


Bookmarks

Posting Permissions

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