[weapon=1]damage=12;resistance=13;etc...
Right now, I'm just testing to see if I can read just the title by itself.
Here's my code that doesn't work;
string input = "[weapon=12]"; regex finder("^\[([a-zA-Z]+)=([0-9]+)\]$"); cmatch matches; if(regex_match(input.c_str(), matches, finder)) { cout << input << " matches " << finder << "." << endl; for(int c = 0; c < matches.size(); c++) { cout << "\t#" << c << " - " << matches[c] << endl; } } else { cout << "No matches were found." << endl; }
This program gives me the following error:
This application has requested the Runtime to terminate in an unusual way. Please contact the application's support team for more information.
If I change the "finder" value to ^\[([a-zA-Z]+=([0-9]+)\]$ (I removed 1 bracket just before the =) it works, but returns this;
[weapon=12] matches ^\[([a-zA-Z]+=([0-9]+)\]$ #0 - [weapon=12] #1 - 12I was hoping it would return 'weapon' as value 1 and '12' as value 2.
I'm using Dev C++ 4.9.9.2 with Boost.Regex
Any help/advice would be much appreciated.
P.S. I also tested the first one in several regex testers, and all of them returned the proper values, so I really have no clue what wrong with this. In the documentation for Boost.Regex, they said that it uses Perl's same grammar and that's what I used to build this one.
Edited by Glasseater, 06 May 2007 - 09:43 AM.