Thread: Check strings which should only contain some characters.

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    26

    Check strings which should only contain some characters.

    Dear all,

    In my case, there are some strings like "NAME_ID", "EMPLOYEE_ID" etc, which should only contain some characters from A to Z (both upper case and small letter) and "_". Currently, there is only one method in my mind of checking if the string only contains above mentioned characters, i.e. using strstr to check it one character by another, which is obviously costive. Therefore, may I happen to know if there is a better way of doing that? Or I have to use the regular expression (from third party, not in C)to do it?

    Bests,

    Qing.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    There are such things as isupper and islower in ctype.h.

  3. #3
    Registered User
    Join Date
    Dec 2006
    Posts
    26
    Quote Originally Posted by tabstop View Post
    There are such things as isupper and islower in ctype.h.
    Hey tabstop,

    Thanks for the hints, points well taken. :0)

    Bests,

    Qing

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 10-29-2008, 03:22 AM
  2. HELP!!!!emergency ~expert please help
    By unknowppl in forum C Programming
    Replies: 1
    Last Post: 08-19-2008, 07:35 AM
  3. Replies: 10
    Last Post: 07-10-2008, 03:45 PM
  4. removing characters from strings
    By Geolingo in forum C++ Programming
    Replies: 1
    Last Post: 04-27-2003, 09:33 PM
  5. damn strings
    By jmzl666 in forum C Programming
    Replies: 10
    Last Post: 06-24-2002, 02:09 AM