1

I am implementing a game in console.

I need to parse strings with escaping, I just cannot split string by space to get parameters. if one of arguments is "Hello my name is \"someone\"" then i should get string >Hello my name is "someone"<

example:

move_player "La la" 10.0 20.0 10.0

this should give me 4 parameters, where I don't count command name.

setplayerid "La la" 24442
rename_player "La la" parameterwithoutquotes

Is there any library for such thing?

2 Answers 2

4

Take a look at boost::tokenizer

Use escaped_list_separator, which separates a string using given character preserving text in quotes.

Sign up to request clarification or add additional context in comments.

Comments

0

couldn't you just use the spaces as a delimter to extract all info from the string?

sorry: mist the part about not using space.

1 Comment

Spaces are usually used to separate arguments. If you'd like to provide ability to enter argument with spaces inside you have to escape them somehow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.