c - Use sscanf for regex purpose -


i have string str, if str composed of pure digits, extract digits int, if not, extract nothing or 0.

for example,

str = "12345";  // composed of pure digits, extract 12345 str = "123abc";  // not pure digits, extract nothing or 0 

can using sscanf? how?

int  value; char unused; if (1 == sscanf(mystring, "%d%c", &value, &unused)) {     // success } else {     // bad input } 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -