Well once I went through and changed all the int's to long's, the program gave all the correct outputs. The issue was that I neglected to replace the int's used for the counters in the for loops.

@nonpuz

when I try to compile your code, my system can't find the "boost/regex.hpp" file.