MSL by example:Regular Expressions
From MSL-Libraries
Jump to navigationJump to searchRegular Expressions
// Generic string matching
string regExpression = "^CLUSTAL W (\\S+)\\s+([\\S\\s]+)$";
string lineToMatch="CLUSTAL W 2.1 multiple sequence alignment";
vector<string> results;
// Line which should match RegEx
if (MslTools::regex(lineToMatch,regExpression,results)){
cout << "PASS test 1\n";
// Print out the matched '()' substrings
for (uint i = 0; i < results.size();i++){
cout << "Match["<<i<<"]: "<<results[i]<<endl;
}
} else {
cerr << "ERROR did not match line properly.\n";
}