Skip to main content
gamedev.net
🔒 Locked

Searching from String

Started by ruellm 2 replies 400+ views
Original Post
ruellm
ruellm
how to search a number from a String. im using String class of C++? example i have a string :"hello 143" i want to search if there exist a number on the String.. hope someone can help me with this..
Monder
Monder
Do you want to search for a specific number or just if there is a number? If it''s the former the standard libary search algorithm can help you out.
ruellm
ruellm
I want to search if there is a number on the string (any number)
SiCrane
SiCrane
You can use std::string::find_first_of() with "0123456789" as a parameter. If the return value is not equal to std::string::npos, then the string contains a number.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.