Search code examples
c++boostc++14boost-spiritboost-spirit-qi

boost::spirit string to array by separator


I need to parse number from string "1/20/10/3/5". Number - is positive integers, "/" is separator.

I write the next expression:

('"' >> +(qi::uint_ ^ "/")  >> '"')

It's work fine, but parser allow the next string "1//3". How I can change my expression to fail that string?


Solution

  • You are using ^, the permutation parser, which matches "/" and/or qi::uint_.

    What you want is the list parser: %.

    ('"' >> qi::uint_ % "/" >> '"')