Get a specific word from a line

Hi there i need some help extracting a specific word that is in quotes from a line.

example: <P id="3" name="starting code" entry="1"></P>

i need to extract the name "starting code"(without quotes) and number 1 in (entry="1").

Thanks.
Are parameters in exact same order and there is no spaces between name and actual value? If so, you can just use string search methods. Otherwise you would better apply regex to it.
You have the line in a std::string.
You can find() the position of name=" .
You can find() the position of next '"'.
Between there is the substr() that you want.

Repeat the procedure for entry=" .
You can directly search for starting code in the string and create a substring from the position,
If that's an XML fragment, then another possibility is to use a parser like RapidXML.
http://rapidxml.sourceforge.net/

Andy
Thanks will try use find()
Topic archived. No new replies allowed.