-4

How to parse a string using boost::spirit excluding defined substrings?

For example, a string must not contain $lf, $pt, $kf

sehe
  • 374,641
  • 47
  • 450
  • 633
alexander.sivak
  • 4,352
  • 3
  • 18
  • 27

1 Answers1

3

You may mean

*(qi::char_ - (qi::lit("$if") | qi::lit("$pt") | qi::lit("$kf"))
sehe
  • 374,641
  • 47
  • 450
  • 633
  • why did you use lit here? – alexander.sivak Nov 17 '13 at 23:42
  • I meant `qi::lit`, fixed. I prefer if my code compiles ([`invalid operands of types ‘const char [...]’ and ‘const char [...]’ to binary ‘operator|’`](http://coliru.stacked-crooked.com/a/b14ef1f9f825cc59)?) – sehe Nov 17 '13 at 23:44
  • qi::char_ parses one character. qi::lit("$if") takes a string. how does your code work? – alexander.sivak Nov 17 '13 at 23:50
  • `*(p)` matches 0 or more repetitions of `p` eagerly (**[documentation](http://www.boost.org/doc/libs/1_55_0/libs/spirit/doc/html/spirit/qi/reference/operator/kleene.html)**). `(p - q)` matches any input that matches `p` iff it doesn't match `q` (**[documentation](http://www.boost.org/doc/libs/1_55_0/libs/spirit/doc/html/spirit/qi/reference/operator/difference.html)**). – sehe Nov 17 '13 at 23:54