fork(1) download
  1. #include <iostream>
  2. #include <regex>
  3. #include <set>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. const auto input = "av*sin_(w*t)+a+b/c+x^2+w3_so^2/2"s;
  9. const regex re{ "\\b([a-zA-Z]\\w*)(?:[^(a-zA-Z0-9_]|$)" };
  10. const set<string> output{ sregex_token_iterator(cbegin(input), cend(input), re, 1), sregex_token_iterator() };
  11.  
  12. for(const auto& i : output) cout << i << endl;
  13. }
Success #stdin #stdout 0s 3560KB
stdin
Standard input is empty
stdout
a
av
b
c
t
w
w3_so
x