Connecting Tech Pros Worldwide Forums | Help | Site Map

String Question

Member
 
Join Date: Mar 2009
Location: San Diego , CA
Posts: 45
#1: May 7 '09
Hello all. So i have a question about searching strings. I have the following if statement...

if (parser.get_token(i,2).at(0) =='#' && parser.get_token(i,2).at(1)=='5'){
...
...
..
}

What I want to do is change where it says "=='5' " to be able to look for all numbers 0-9 instead of just 5. Any help would be awesome. Thanks.



gpraghuram's Avatar
Expert
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,258
#2: May 7 '09

re: String Question


Then u shuld change the condition like this

Expand|Select|Wrap|Line Numbers
  1. if (parser.get_token(i,2).at(0) =='#' && (parser.get_token(i,2).at(1)>='0' &&(parser.get_token(i,2).at(1)<='9' ){
  2. }
raghu
Expert
 
Join Date: Mar 2008
Location: Naperville, Illinois U.S.
Posts: 830
#3: May 7 '09

re: String Question


or perhaps
Expand|Select|Wrap|Line Numbers
  1. #include <ctype.h>   ...   or <ctype> if this is C++
  2. if (parser.get_token(i,2).at(0) =='#' && isdigit(parser.get_token(i,2).at(1) ){
  3. }
Member
 
Join Date: Mar 2009
Location: San Diego , CA
Posts: 45
#4: May 10 '09

re: String Question


thanks guys for the help
Reply

Tags
if statements, numbers, string


Similar C / C++ bytes