How to show regex output in pair in c++? -


i dont know if makes sense or not here is
there way can 2 words regex result each time?
supose have text file contains string such following :

alex fenix engineer works ford automotive company. personal id <123456>;etc....

basically if use \w list of :

alex fenix  engineer , etc  

they separated white space , punctuation marks asking , whether there way have list such :

alex fenix engineer works ford automotive company personal id 123456 

how can achieve such format?
possible or should store first results in array , iterate through them , create second list?
way please note item alex fenix abstraction of map or container that.
reason asking trying see if there way can directly read file , apply regex on , second list without further processing overhead (i mean reading map or string , iterating through them , creating pairs of tokens , carry on ever needed )

try regex

\w \w 

it match word followed space , word.

although can achieve such format relatively easy without using regex. take @ instance:

#include <iostream> #include <sstream> #include <string> #include <algorithm>  int main() {     std::string s("alex fenix engineer works ford automotive company. personal id <123456>");      // remove occurences of '.', '<' or '>'.     s.assign(begin(s), std::remove_if(begin(s), end(s), [] (const char c) {         return (c == '.' || c == '<' || c == '>');     }));      // tokenize.     std::istringstream iss(s);     std::string t1, t2;     while (iss >> t1 >> t2) {         std::cout << t1 << " " << t2 << std::endl;     } } 

output:

alex fenix engineer works ford automotive company personal id 123456 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -