C++ (Qt) std::string std_src = "author = {Singh, A. and S\"urgers, C. },\n year = \"2013\"\n "; parse_param param(",=", " \t\n"); param.add_quote('{', '}'); param.add_quote('"','"'); string_parser parser(param); size_t pos = 0; while ((pos = parser.next_token(std_src, pos, split_behavior::keep_empty_parts)) != std::string::npos) { std::cout << parser.result() << std::endl << parser.token() << std::endl; pos += parser.matched_length(); }
Bashauthor={Singh, A. and S"urgers, C. },year="2013"
C++ (Qt) QString src = "author = {Singh, A. and S\"urgers, C. },\n year = \"2013\"\n "; CParseParam cparam(" \t\n", ",="); cparam.AddQuote(10, "{", "}"); cparam.AddQuote(10, "\"", "\""); QStringRef temp; QStringParser cparser(src, cparam); while(cparser.NextToken(temp)) { qDebug() << temp; }
Bash"author" "=" "{Singh, A. and S"urgers, C. }, year = "2013" "
C++ (Qt)std::string str = "text1, text2: text3, text4";boost::tokenizer<boost::char_separator<char>> tok(str, boost::char_separator<char>(",:"));for (auto it = tok.begin(); it != tok.end(); ++it) std::cout << *it << std::endl;
C++ (Qt)enum class empty_token_policy { drop_empty_tokens, keep_empty_tokens }; template <class CharT>class simple_char_separator{public: typedef std::basic_string<CharT> string_type; typedef typename string_type::const_iterator const_iterator; void reset() {} bool operator()(const_iterator & next, const_iterator end, string_type & tok) const { } };
C++ (Qt)#include <iostream>#include "core/spec_token_functions.h"#include <boost/tokenizer.hpp> int main(){ std::string str = "text1, {text2, text3.} : text4. \"text5, abs\" "; bibmake::core::quote_list<char> quotes('{', '}'); quotes.add_quote('"', '"'); std::string dropped_delims = ",."; std::string kept_delims = ":"; typedef bibmake::core::spec_char_separator<char> spec_char_separator; boost::tokenizer<spec_char_separator> tok(str, spec_char_separator(dropped_delims, kept_delims, quotes)); for (auto s : tok) { std::cout << s << std::endl; } return 0;}
Bashtext1 {text2, text3.} : text4 "text5, abs"