Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > any other idea of validating user input except regular expressions

Reply
Thread Tools

any other idea of validating user input except regular expressions

 
 
Oliver Bleckmann
Guest
Posts: n/a
 
      11-30-2006
how can i find out a string consists of letters/ numbers or other signs
and especially how can i validate a date?


 
Reply With Quote
 
 
 
 
BobR
Guest
Posts: n/a
 
      12-01-2006

Oliver Bleckmann wrote in message ...
>how can i find out a string consists of letters/ numbers or other signs




#include <iostream>
#include <ostream>
#include <string>
#include <ccytpe>

int main(){
using std::cout; // for NG post
int Inum(0);
double Dnum(0);
std::string TestForNum("Hi 4 76.5num 42.7e-5");
cout<<"Test string = "<<TestForNum<<"."<<std::endl;
for(size_t i(0); i < TestForNum.size(); ++i){
cout<<"char at "<<i<<" is "<<TestForNum.at(i)<<", an ";
if( std::isdigit( TestForNum.at(i) ) ){
std::istringstream sis( TestForNum.substr( i ) );
sis >> Inum;
sis.clear();
sis.str( TestForNum.substr( i ) );
sis >> Dnum;
sis.clear();
cout<<"digit Inum="<<Inum
<<" Dnum="<<Dnum<<std::endl;
}
else{ cout<<"alpha"<<std::endl;}
}
return 0;
} // main()


>and especially how can i validate a date?


Call her up and ask her if it's still on! Duh!

--
Bob R
POVrookie


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking that user has entered a word or words in text input form using regular expressions... Luke Matuszewski Javascript 8 04-22-2006 07:47 AM
Regular expressions: string substitution with pcre or any other library? Bernd Muent C++ 2 02-15-2006 01:31 PM
Validating paths using regular expressions Chris Leffer ASP .Net 0 02-21-2005 12:57 PM
Nested conditional expressions ---- good idea/bad idea? nimmi_srivastav@yahoo.com C Programming 10 02-02-2005 10:51 PM
Add custom regular expressions to the validation list of available expressions Jay Douglas ASP .Net 0 08-15-2003 10:19 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57