Difference between revisions of "MSL by example"

From MSL-Libraries
Jump to navigationJump to search
(Created page with '== Regular Expressions == // Generic string matching string regExpression = "^CLUSTAL W (\\S+)\\s+([\\S\\s]+)$"; string lineToMatch="CLUSTAL W 2.1 multiple sequence alignment…')
 
Line 4: Line 4:
 
  string regExpression = "^CLUSTAL W (\\S+)\\s+([\\S\\s]+)$";
 
  string regExpression = "^CLUSTAL W (\\S+)\\s+([\\S\\s]+)$";
 
  string lineToMatch="CLUSTAL W 2.1 multiple sequence alignment";
 
  string lineToMatch="CLUSTAL W 2.1 multiple sequence alignment";
 
+
 
  vector<string> results;
 
  vector<string> results;
 
+
 
  // Line which should match RegEx
 
  // Line which should match RegEx
 
  if (MslTools::regex(lineToMatch,regExpression,results)){
 
  if (MslTools::regex(lineToMatch,regExpression,results)){

Revision as of 15:51, 16 February 2010

Regular 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";
}