RxTokenizer tk("color = (1.34, 0.21, 0.2), x = 1.23e-5f,."); while(tk.hasNext()) qDebug() << tk.nextToken();// "color" "=" "(" "1.34" "0.21" "0.2" ")" "x" "=" "1.23e-5f"
RxTokenizer tk("color = (1.34, 0.21, 0.2), x = 1.23e-5f,. "); tk.addToken(",\\."); while(tk.hasNext()) qDebug()<< tk.nextToken();// "color" "=" "(" "1.34" "0.21" "0.2" ")" "x" "=" "1.23e-5f" ",."
RxTokenizer tk; tk.setTokens("\\w+"); tk.setString("color = (1.34, 0.21, 0.2), x = 1.23e-5f,. "); while(tk.hasNext()) qDebug()<< tk.nextToken(); // "color" "1" "34" "0" "21" "0" "2" "x" "1" "23e" "5f" tk.setString("color red green,blue"); while(tk.hasNext()) qDebug()<< tk.nextToken(); // "color" "red" "green" "blue"
#include <iostream>#include <string>#include <boost/tokenizer.hpp>int main(int argc, char **argv){ typedef boost::tokenizer<boost::char_separator<char> > tokenizer; std::string str = "color = (1.34, 0.21, 0.2), x = 1.23e-5f,."; boost::char_separator<char> sep(" ,", "()="); tokenizer tokens(str, sep); tokenizer::iterator it = tokens.begin(); for(; it != tokens.end(); ++it) std::cout << "<" << *it << "> "; std::cout << std::endl; return 1;}// <color> <=> <(> <1.34> <0.21> <0.2> <)> <x> <=> <1.23e-5f> <.>
C++ (Qt)MY_EXPORT void DoSomething( const char * in, char * out );