I dont know if it makes any sense or not but here it is
Is there a way that i can get two words from a regex result each time?
supose i have a text file which contains an string such as the following :
Alex Fenix is an Engineer who works for Ford Automotive Company. His Personal ID is <123456>;etc....
basically if i use \w
i would get a list of :
Alex
Fenix
is
an
Engineer
and etc
They are all separated by white space and punctuation marks what i am asking is , whether there is a way to have a list such as :
Alex Fenix
is an
Engineer who
works for
Ford Automotive
Company His
Personal ID
is 123456
How can i achieve such a format?
Is it even possible or should i store those first results in an array and then iterate through them and create the second list?
By the way please note that the item Alex Fenix is actually an abstraction of a map or any container like that.
The reason i am asking is that i am trying to see if there is any way that i can directly read a file and apply a regex on it and get this second list without any further processing overhead
(I mean reading into a map or string , then iterating through them and creating pairs of the tokens and then carry on what ever is needed )